mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2d0e0335c | ||
|
|
b4fa9ae676 | ||
|
|
5aa6c4cd36 | ||
|
|
ad8187aefd | ||
|
|
1bfd0388b0 | ||
|
|
cbd7649e02 | ||
|
|
fc83cf7446 | ||
|
|
2bbf0179fc | ||
|
|
dcd1107a9f | ||
|
|
bf07a473ae | ||
|
|
f9b6f22ecf | ||
|
|
fcd6e12c03 | ||
|
|
d7a755c08b | ||
|
|
b776edd026 | ||
|
|
9a289e072c | ||
|
|
4bc503d81d | ||
|
|
4e252226a6 | ||
|
|
ca184a08c9 | ||
|
|
cceec65c38 | ||
|
|
fac78b331b | ||
|
|
ae49b9f3c9 | ||
|
|
edf25e43c0 | ||
|
|
4a563b9cf6 | ||
|
|
ea5e9015e7 | ||
|
|
d8c392b69a | ||
|
|
035783ae0c | ||
|
|
08a3904127 | ||
|
|
cae6d2201c | ||
|
|
b8d38aa2c0 | ||
|
|
d685762382 | ||
|
|
c96de52402 | ||
|
|
b4e6f54d55 | ||
|
|
d145985058 | ||
|
|
03685d6139 | ||
|
|
620c796095 | ||
|
|
37846080a7 | ||
|
|
e24034ee10 | ||
|
|
9f4990cd90 | ||
|
|
7026280df3 | ||
|
|
df9d1d11d5 | ||
|
|
e60a8bc5fe | ||
|
|
1496780fa4 | ||
|
|
2cb2136348 | ||
|
|
e368a5dbcb | ||
|
|
e3dfcb96d1 | ||
|
|
f845ef0add | ||
|
|
cb01f542c0 | ||
|
|
054738329d | ||
|
|
e85de83289 | ||
|
|
06090e06cd | ||
|
|
7729997d96 | ||
|
|
8818eaa2ec | ||
|
|
b715d70366 | ||
|
|
2c6132a460 |
No files matched your search
+101
-11
@@ -60,9 +60,17 @@ jobs:
|
||||
- os: ubuntu-24.04
|
||||
lib: libraea_bundle.so
|
||||
extra: raea-perceive
|
||||
runs-on: ${{ matrix.os }}
|
||||
# a faster runner when the repo names one: vars RELEASE_MAC_RUNNER, RELEASE_LINUX_RUNNER, RELEASE_WINDOWS_RUNNER hold
|
||||
# a JSON list of runs-on labels (Namespace's: a machine and a cache volume); else GitHub's
|
||||
# own, a 3-core M1 with 7 GB on the Mac, where a cold build took 3 hours
|
||||
runs-on: ${{ (matrix.os == 'macos-15' && vars.RELEASE_MAC_RUNNER && fromJSON(vars.RELEASE_MAC_RUNNER)) || (matrix.os == 'ubuntu-24.04' && vars.RELEASE_LINUX_RUNNER && fromJSON(vars.RELEASE_LINUX_RUNNER)) || matrix.os }}
|
||||
# a cold thin-LTO build of raea-cli with the plugin catalog is the long part; GitHub's own limit is 6 hours
|
||||
timeout-minutes: 340
|
||||
env:
|
||||
# the compile cache (the "Compile cache" step): an R2 bucket, read and written by every build
|
||||
RELEASE_CACHE_ENDPOINT: ${{ secrets.RELEASE_CACHE_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_CACHE_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_CACHE_SECRET }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -95,7 +103,7 @@ jobs:
|
||||
# rc3's build left 576 MB of macos-15's 320 GB free, and rc4's dSYMs (#88) ran it out linking raea-page-host
|
||||
# (ld: write() failed, errno=28): the image's other Xcodes and the Android and .NET SDKs go first
|
||||
- name: Room for the build
|
||||
if: runner.os == 'macOS' && env.RAEA_PROMOTED_FROM == ''
|
||||
if: runner.os == 'macOS' && env.RAEA_PROMOTED_FROM == '' && vars.RELEASE_MAC_RUNNER == ''
|
||||
run: |
|
||||
df -h . | tail -1
|
||||
keep=$(cd "$(xcode-select -p)/../.." && pwd -P)
|
||||
@@ -104,14 +112,48 @@ jobs:
|
||||
wait
|
||||
echo "kept $keep"
|
||||
df -h . | tail -1
|
||||
# The compile cache: sccache on an R2 bucket. GitHub's own cache can't carry a release build: a tag's run reads
|
||||
# only its own tag's caches and the default branch's (so rc3's never reached rc4), and the repo's 10 GB are CI's.
|
||||
# A bucket is read by every tag. A cold build fills it; a candidate after a small change compiles only the crates
|
||||
# that changed and the ones above them. Linking (thin LTO) and build scripts' runs aren't cached. With no secrets
|
||||
# (a fork) the build runs as before, uncached.
|
||||
# the build folder and cargo's downloads kept between runs on the runner's cache volume (a Namespace runner,
|
||||
# whose labels attach one), so a candidate rebuilds only what changed and links;
|
||||
# sccache below still serves the workspace's own crates, which a fresh checkout's file times mark as changed
|
||||
- name: The build folder, kept on the runner's cache volume
|
||||
if: env.RAEA_PROMOTED_FROM == '' && startsWith(runner.name, 'nsc-')
|
||||
uses: namespacelabs/nscloud-cache-action@v1
|
||||
with:
|
||||
path: |
|
||||
${{ github.workspace }}/target
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
- name: Compile cache (sccache)
|
||||
if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
|
||||
uses: mozilla-actions/[email protected]
|
||||
# the script from this workflow's own commit: a dispatched run (a dry run that fills the cache) builds an older
|
||||
# tag, whose tree may not have it
|
||||
- name: The compile cache's script
|
||||
if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
path: .workflow
|
||||
sparse-checkout: tools/release/compile-cache.sh
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Use the compile cache
|
||||
if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
|
||||
run: bash .workflow/tools/release/compile-cache.sh
|
||||
- name: Build
|
||||
if: env.RAEA_PROMOTED_FROM == ''
|
||||
run: |
|
||||
feat=$(bash tools/bevy-plugins.sh features sdk/raea/bench/bevy-plugins)
|
||||
cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
|
||||
cargo build --profile dist --locked -p raea-rune-host
|
||||
cargo build --profile dist --locked -p raea-page-host --features window
|
||||
if [ -n "${{ matrix.extra }}" ]; then cargo build --profile dist --locked -p ${{ matrix.extra }}; fi
|
||||
t() { s=$SECONDS; "$@"; echo "::notice::${{ runner.os }} $(( (SECONDS - s) / 60 )) min: ${*:7}"; }
|
||||
t cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
|
||||
t cargo build --profile dist --locked -p raea-rune-host
|
||||
t cargo build --profile dist --locked -p raea-page-host --features window
|
||||
if [ -n "${{ matrix.extra }}" ]; then t cargo build --profile dist --locked -p ${{ matrix.extra }}; fi
|
||||
if [ -n "${RUSTC_WRAPPER:-}" ]; then sccache --show-stats; fi
|
||||
mkdir ship
|
||||
cp target/dist/raea target/dist/${{ matrix.lib }} target/dist/raea-rune-host target/dist/raea-page-host ship/
|
||||
if [ -n "${{ matrix.extra }}" ]; then cp target/dist/${{ matrix.extra }} ship/; fi
|
||||
@@ -124,6 +166,8 @@ jobs:
|
||||
run: bash tools/release/promoted-bins.sh "$RAEA_PROMOTED_FROM" ship
|
||||
# the packing and its checks need only ship/, and macos-15's disk ran out packing rc1 with target/ kept
|
||||
- name: Free the build's disk
|
||||
# not the cache volume's build folder, which the next candidate starts from (a bind mount on Linux)
|
||||
if: ${{ !startsWith(runner.name, 'nsc-') }}
|
||||
run: |
|
||||
df -h . | tail -1
|
||||
rm -rf target
|
||||
@@ -177,8 +221,13 @@ jobs:
|
||||
# accept no licence and download no Microsoft files). The C runtime is the DLL one (the VC++ redistributable): ort's
|
||||
# prebuilt ONNX Runtime is built against it, so crt-static doesn't link (LNK2019 on __imp_ symbols, 10-29).
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
runs-on: ${{ (vars.RELEASE_WINDOWS_RUNNER && fromJSON(vars.RELEASE_WINDOWS_RUNNER)) || 'windows-latest' }}
|
||||
timeout-minutes: 350
|
||||
env:
|
||||
# the compile cache, as build's
|
||||
RELEASE_CACHE_ENDPOINT: ${{ secrets.RELEASE_CACHE_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_CACHE_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_CACHE_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
@@ -195,6 +244,21 @@ jobs:
|
||||
- name: Toolchain (rust-toolchain.toml's pin)
|
||||
if: env.RAEA_PROMOTED_FROM == ''
|
||||
run: rustup show active-toolchain || rustup toolchain install
|
||||
# nasm, which rav1d's and openh264-sys2's build scripts run: GitHub's Windows image has 2.16, Namespace's has none
|
||||
# (rc3's dry run there stopped at "Unable to run nasm: program not found"). Always NASM's own 2.16.03 zip, never
|
||||
# Chocolatey's: rc4 took Chocolatey's newest, and raea.exe failed to link 135 of openh264's SIMD routines
|
||||
# (WelsSampleSad16x8_sse2 and the rest unresolved) though openh264's C++ was built to call them
|
||||
- name: nasm
|
||||
if: env.RAEA_PROMOTED_FROM == ''
|
||||
run: |
|
||||
v=2.16.03
|
||||
curl -fsSL --retry 3 -o "$RUNNER_TEMP/nasm.zip" "https://www.nasm.us/pub/nasm/releasebuilds/$v/win64/nasm-$v-win64.zip"
|
||||
unzip -q "$RUNNER_TEMP/nasm.zip" -d "$RUNNER_TEMP"
|
||||
# Git Bash on Windows has no /dev/stderr (rc5 stopped here): capture, print, then match
|
||||
out=$("$RUNNER_TEMP/nasm-$v/nasm.exe" -v)
|
||||
echo "$out"
|
||||
case $out in *"version $v"*) ;; *) echo "::error::expected NASM $v, got: $out"; exit 1 ;; esac
|
||||
echo "$RUNNER_TEMP/nasm-$v" >> "$GITHUB_PATH"
|
||||
# jq for Windows ends -r lines with CRLF, so tools/bevy-plugins.sh read "ahoy\r" and lost its Bevy 0.20 block
|
||||
# (feature `ahoy` not found, 11-04); -b writes LF
|
||||
- name: jq that writes LF
|
||||
@@ -219,14 +283,40 @@ jobs:
|
||||
done < <(tr -d '\r' < tools/release/models.tsv)
|
||||
# the app targets' hosts a cargo call each: with raea-cli's crates in one call taffy's features unify and
|
||||
# rune-taffy doesn't build; raea-perceive (`raea song`'s map, #43) a call of its own too
|
||||
- name: The build folder, kept on the runner's cache volume (as build's)
|
||||
if: env.RAEA_PROMOTED_FROM == '' && startsWith(runner.name, 'nsc-')
|
||||
uses: namespacelabs/nscloud-cache-action@v1
|
||||
with:
|
||||
path: |
|
||||
${{ github.workspace }}/target
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
- name: Compile cache (sccache, as build's)
|
||||
if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
|
||||
uses: mozilla-actions/[email protected]
|
||||
# the script from this workflow's own commit: a dispatched run (a dry run that fills the cache) builds an older
|
||||
# tag, whose tree may not have it
|
||||
- name: The compile cache's script
|
||||
if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
path: .workflow
|
||||
sparse-checkout: tools/release/compile-cache.sh
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Use the compile cache
|
||||
if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
|
||||
run: bash .workflow/tools/release/compile-cache.sh
|
||||
- name: Build
|
||||
if: env.RAEA_PROMOTED_FROM == ''
|
||||
run: |
|
||||
feat=$(bash tools/bevy-plugins.sh features sdk/raea/bench/bevy-plugins)
|
||||
cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
|
||||
cargo build --profile dist --locked -p raea-rune-host
|
||||
cargo build --profile dist --locked -p raea-page-host --features window
|
||||
cargo build --profile dist --locked -p raea-perceive
|
||||
t() { s=$SECONDS; "$@"; echo "::notice::Windows $(( (SECONDS - s) / 60 )) min: ${*:7}"; }
|
||||
t cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
|
||||
t cargo build --profile dist --locked -p raea-rune-host
|
||||
t cargo build --profile dist --locked -p raea-page-host --features window
|
||||
t cargo build --profile dist --locked -p raea-perceive
|
||||
if [ -n "${RUSTC_WRAPPER:-}" ]; then sccache --show-stats; fi
|
||||
- name: The candidate's binaries (tools/release/promoted-bins.sh)
|
||||
if: env.RAEA_PROMOTED_FROM != ''
|
||||
env:
|
||||
|
||||
Generated
+10
@@ -14767,6 +14767,7 @@ dependencies = [
|
||||
"raea-sys-framepass",
|
||||
"raea-sys-grass",
|
||||
"raea-sys-grid",
|
||||
"raea-sys-hold",
|
||||
"raea-sys-look",
|
||||
"raea-sys-matchmove",
|
||||
"raea-sys-material",
|
||||
@@ -15178,6 +15179,7 @@ dependencies = [
|
||||
"raea-runtime-react",
|
||||
"raea-runtime-sound",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-hold",
|
||||
"raea-sys-mix",
|
||||
"serde_json",
|
||||
"twox-hash",
|
||||
@@ -15719,6 +15721,14 @@ dependencies = [
|
||||
"raea-sys-frame",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-hold"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-sys-frame",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-image"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -103,6 +103,7 @@ members = [
|
||||
"systems/page-net",
|
||||
"systems/page-ops",
|
||||
"systems/frame",
|
||||
"systems/hold",
|
||||
"systems/layers",
|
||||
"systems/splat",
|
||||
"systems/sprite",
|
||||
|
||||
@@ -65,6 +65,7 @@ pub(crate) fn approve(enc: &mut Encoders, dir: &Folder, fp: &Fingerprint, args:
|
||||
words: None,
|
||||
at: 0,
|
||||
pin: None,
|
||||
band: None,
|
||||
};
|
||||
l.push(row, &features(&c, *a, *b));
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ pub fn rows(enc: &mut Encoders, who: &str, files: &[PathBuf], per: usize, l: &mu
|
||||
words: None,
|
||||
at: 0,
|
||||
pin: None,
|
||||
band: None,
|
||||
};
|
||||
l.push(r, &features(c, 0.0, WIN));
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn row(axis: &str, source: &str) -> Row {
|
||||
Row { media: "m".into(), a: 0.0, b: 2.0, axis: axis.into(), bad: true, weight: 1.0, who: "me".into(), source: source.into(), project: "p".into(), kind: None, region: None, words: None, at: 0, pin: None }
|
||||
Row { media: "m".into(), a: 0.0, b: 2.0, axis: axis.into(), bad: true, weight: 1.0, who: "me".into(), source: source.into(), project: "p".into(), kind: None, region: None, words: None, at: 0, pin: None, band: None }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -12,44 +12,13 @@
|
||||
use crate::{flag, has, words};
|
||||
use raea_sys_fingerprint::folder::Folder;
|
||||
use raea_sys_fingerprint::taxonomy::Fingerprint;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use raea_sys_fingerprint_use::reading::{Reading, agreement, earned};
|
||||
use raea_sys_fingerprint_use::reading::span;
|
||||
use serde_json::{Value, json};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// FP5b's bar, out of every 50 checked
|
||||
pub const KIND_BAR: f64 = 45.0 / 50.0;
|
||||
pub const AXIS_BAR: f64 = 40.0 / 50.0;
|
||||
pub const INBOX: &str = "fingerprint";
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Reading {
|
||||
pub note: String,
|
||||
pub text: String,
|
||||
pub who: String,
|
||||
pub media: PathBuf,
|
||||
pub t: f64,
|
||||
pub project: String,
|
||||
/// defect, direction, praise or both
|
||||
pub kind: String,
|
||||
pub axis: Option<String>,
|
||||
/// how it was read: kimi or claude
|
||||
pub by: String,
|
||||
/// the person's check: Some(true) agreed, Some(false) not; None until asked
|
||||
#[serde(default)]
|
||||
pub kind_ok: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub axis_ok: Option<bool>,
|
||||
/// a span pin's end: the label covers t..to (FP11b)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub to: Option<f64>,
|
||||
/// where in the frame the note's marks say the thing is, x0,y0,x1,y1 in 0-1 (FP11b)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub region: Option<[f32; 4]>,
|
||||
/// the layers under the pin's x,y in the layer pass, on a render with one (FP5a)
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub layers: Vec<String>,
|
||||
}
|
||||
|
||||
|
||||
/// A post's video on this machine: the renders library, else the project's own folder
|
||||
fn media(project: &Path, m: &Value) -> Option<PathBuf> {
|
||||
@@ -88,7 +57,7 @@ pub fn pinned(project: &Path) -> Vec<Reading> {
|
||||
let to = n["pin"]["to"].as_f64().filter(|&to| to > t);
|
||||
let at = n["pin"]["x"].as_f64().zip(n["pin"]["y"].as_f64()).map(|(x, y)| [x - 0.01, y - 0.01, x + 0.01, y + 0.01].map(|v| v.clamp(0.0, 1.0)));
|
||||
let layers = at.map(|b| raea_sys_fingerprint_things::located::layers(&video, t, b)).unwrap_or_default();
|
||||
out.push(Reading { note: n["id"].as_str().unwrap_or("").into(), text: text.into(), who: n["author"]["name"].as_str().unwrap_or("me").into(), media: video.clone(), t, project: name.clone(), to, region: raea_sys_fingerprint_use::grow::marked(&n["pin"]), layers, ..Default::default() });
|
||||
out.push(Reading { note: n["id"].as_str().unwrap_or("").into(), text: text.into(), who: n["author"]["name"].as_str().unwrap_or("me").into(), media: video.clone(), t, project: name.clone(), to, region: raea_sys_fingerprint_use::grow::marked(&n["pin"]), layers, band: raea_sys_fingerprint_use::grow::sound_band(&n["pin"]), ..Default::default() });
|
||||
}
|
||||
}
|
||||
out
|
||||
@@ -201,18 +170,6 @@ pub(crate) fn read_here(args: &[String], cwd: &Path) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// The share of checked readings the person agreed with, for kind and for axis, and how many were checked
|
||||
pub fn agreement(r: &[Reading]) -> (Option<f64>, Option<f64>, usize) {
|
||||
let share = |v: Vec<bool>| (!v.is_empty()).then(|| v.iter().filter(|x| **x).count() as f64 / v.len() as f64);
|
||||
let checked = r.iter().filter(|x| x.kind_ok.is_some()).count();
|
||||
(share(r.iter().filter_map(|x| x.kind_ok).collect()), share(r.iter().filter_map(|x| x.axis_ok).collect()), checked)
|
||||
}
|
||||
|
||||
/// Whether the readings have earned training (FP5b): 50 checked, the kind right 45 times and the axis 40
|
||||
pub fn earned(r: &[Reading]) -> bool {
|
||||
matches!(agreement(r), (Some(k), Some(a), n) if n >= 50 && k >= KIND_BAR && a >= AXIS_BAR)
|
||||
}
|
||||
|
||||
/// The choices a reading is checked with, and what each says about kind and axis
|
||||
pub const CHOICES: [(&str, bool, bool); 4] = [("Right", true, true), ("Right kind, wrong axis", true, false), ("Wrong kind", false, false), ("Right axis, wrong kind", false, true)];
|
||||
|
||||
@@ -296,8 +253,9 @@ pub(crate) fn learn(enc: &mut raea_sys_columns::Encoders, dir: &Folder, l: &mut
|
||||
(None, true) => continue,
|
||||
};
|
||||
let c = enc.columns(&x.media)?;
|
||||
// a span is the label's time; a moment, 1.5 s before the pin to 0.5 s after (FP11b)
|
||||
let (a, b) = x.to.map_or(((x.t - 1.5).max(0.0), (x.t + 0.5).min(c.dur)), |to| (x.t.max(0.0), to.min(c.dur)));
|
||||
// a span is the label's time (a scene's, a box's on the sound: FP11c), half a second at least; a moment, 1.5 s
|
||||
// before the pin to 0.5 s after (FP11b)
|
||||
let (a, b) = x.to.map_or(((x.t - 1.5).max(0.0), (x.t + 0.5).min(c.dur)), |to| span(x.t, to, c.dur));
|
||||
if b - a < 0.5 {
|
||||
continue;
|
||||
}
|
||||
@@ -307,7 +265,9 @@ pub(crate) fn learn(enc: &mut raea_sys_columns::Encoders, dir: &Folder, l: &mut
|
||||
let shot = seed.and_then(|s| raea_sys_fingerprint_use::grow::through(&x.media, x.t, c.dur, s, 2.0).ok().flatten()).filter(|w| !w.is_empty());
|
||||
for (a, b, region) in shot.map_or_else(|| vec![(a, b, seed)], |w| w.into_iter().map(|(a, b, r)| (a, b, Some(r))).collect()) {
|
||||
let (media, axis, who, project, kind, words) = (c.media.clone(), axis.clone(), x.who.clone(), x.project.clone(), Some(x.note.clone()), Some(x.text.clone()));
|
||||
let row = raea_sys_fingerprint::evidence::Row { media, a, b, axis, bad, weight: 1.0, who, source: "note".into(), project, kind, region, words, at: 0, pin: None };
|
||||
// a defect's box on the sound keeps its pitch band (FP11c)
|
||||
let band = x.band.filter(|_| bad);
|
||||
let row = raea_sys_fingerprint::evidence::Row { media, a, b, axis, bad, weight: 1.0, who, source: "note".into(), project, kind, region, words, at: 0, pin: None, band };
|
||||
l.push(row, &raea_sys_fingerprint::evidence::features(&c, a, b));
|
||||
}
|
||||
made += 1;
|
||||
@@ -334,13 +294,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn notes_train_only_once_the_person_agrees_enough() {
|
||||
let r = |k: bool, a: bool| Reading { kind_ok: Some(k), axis_ok: Some(a), ..Default::default() };
|
||||
let mut v: Vec<Reading> = (0..45).map(|_| r(true, true)).collect();
|
||||
v.extend((0..5).map(|_| r(false, false)));
|
||||
assert!(earned(&v), "45 and 45 of 50");
|
||||
v[0] = r(false, true);
|
||||
assert!(!earned(&v), "44 kinds of 50 is under the bar");
|
||||
assert!(!earned(&v[..40]), "fewer than 50 checked");
|
||||
fn a_box_on_the_sound_is_a_reading_s_span_and_band_not_a_region() {
|
||||
let dir = std::env::temp_dir().join(format!("fp11c-{}", std::process::id()));
|
||||
std::fs::create_dir_all(dir.join(".raea/feed")).unwrap();
|
||||
std::fs::write(dir.join("a.mp4"), b"").unwrap();
|
||||
let note = json!({"id": "n1", "text": "that hiss", "author": {"kind": "person", "name": "me"}, "pin": {"kind": "time", "t": 2.0, "to": 4.0, "marks": [{"kind": "box", "on": "sound", "points": [[0.2, 0.9], [0.4, 0.6]]}]}});
|
||||
std::fs::write(dir.join(".raea/feed/p.json"), json!({"media": [{"kind": "video", "path": "a.mp4"}], "notes": [note]}).to_string()).unwrap();
|
||||
let r = pinned(&dir);
|
||||
std::fs::remove_dir_all(&dir).ok();
|
||||
assert_eq!(r.len(), 1);
|
||||
assert_eq!((r[0].t, r[0].to, r[0].band, r[0].region), (2.0, Some(4.0), Some([0.6, 0.9]), None));
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ use raea_sys_fingerprint::pairs::difference;
|
||||
use std::path::Path;
|
||||
|
||||
fn row(media: &str, a: f64, b: f64, axis: &str, weight: f32, who: &str, project: String, words: Option<String>) -> Row {
|
||||
Row { media: media.into(), a, b, axis: axis.into(), bad: true, weight, who: who.into(), source: "pair".into(), project, kind: None, region: None, words, at: 0, pin: None }
|
||||
Row { media: media.into(), a, b, axis: axis.into(), bad: true, weight, who: who.into(), source: "pair".into(), project, kind: None, region: None, words, at: 0, pin: None, band: None }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ pub(crate) fn run(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -
|
||||
continue;
|
||||
}
|
||||
let who = fp.who.clone().unwrap_or_else(|| "me".into());
|
||||
let row = Row { media: c.media.clone(), a, b, axis: x.axis.clone(), bad: *yes, weight: 1.0, who, source: "postmortem".into(), project: name.clone(), kind: None, region: None, words: Some(x.words.clone()), at: 0, pin: None };
|
||||
let row = Row { media: c.media.clone(), a, b, axis: x.axis.clone(), bad: *yes, weight: 1.0, who, source: "postmortem".into(), project: name.clone(), kind: None, region: None, words: Some(x.words.clone()), at: 0, pin: None, band: None };
|
||||
l.push(row, &features(&c, a, b));
|
||||
}
|
||||
dir.write_ledger(&l)?;
|
||||
|
||||
@@ -252,6 +252,7 @@ fn teach(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result<
|
||||
words: flag(args, "--words").map(str::to_string),
|
||||
at: 0,
|
||||
pin: None,
|
||||
band: None,
|
||||
};
|
||||
let mut l = dir.ledger()?;
|
||||
l.push(row, &features(&c, a, b));
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
@spec
|
||||
Feature: Feed tasks: the graph view's layering, the to-do list, and sessions started outside the app
|
||||
Shane, 2026-11-13: "note to ship with this next batch for release is that in the react graph view when i zoom in it
|
||||
ends up obstructing other buttons and gui outside of the stage and across the app, so we need to make sure layering
|
||||
works there and remove the agents button in the top right of feed and inbox for a checkbox and this is a editable
|
||||
todolist built to look minimal, skimmable and easy to read with the ability to click into a task to see more
|
||||
details. the other note to add is in the timeline if an agent is currently running even if i have initiated the
|
||||
session myself in terminal or an app and it is still claimed or working on it without being terminated, meaning its
|
||||
still open or the session is active, we should see it in the feed and see updates from it. this should help tie
|
||||
into the todolist stuff too."
|
||||
|
||||
Three parts. Each is done when it works in raea's window (not only in Chrome) and has its tests.
|
||||
|
||||
Background:
|
||||
Given the app's code is apps/app (raea-feed); its branch for parts 2 and 3 is feed-tasks, part 1 is on its main
|
||||
And a window check is a headless raea window of the session's own: `node blitz/pw-run.mjs SPEC` on the BLITZ_E2E
|
||||
bundle, RAEA_PAGE_HOST_BIN a copy of the page host, a fresh raea.root each run
|
||||
|
||||
Rule: FT1. The graph view stays in its own box
|
||||
# Status 11-13: built, in 0.1.3. Engine 37846080a (vendor/blitz-dom/src/node/node.rs, sdk/ui/src/dom/input.ts, a unit test
|
||||
# in sdk/ui/test/dom.test.tsx); app raea-feed #11 (AskCanvas clipped at its box, e2e/canvas-layer.spec.ts).
|
||||
# Cause: Chrome never showed it. In raea's window the canvas was DRAWN clipped, but neither hit test honoured an
|
||||
# overflow clip: blitz-dom's hit_inner tested a clipping box's children wherever they overflowed to, and sdk/ui's
|
||||
# hit dropped the inherited clip at a child with its own z-index and replaced it at a child that clips (a card is
|
||||
# overflow-hidden). Both halves are needed: with only sdk/ui fixed, elementFromPoint is right and a real press
|
||||
# still lands on the canvas (the host's target wins). Checked: the spec in Chrome and in the window; the app's
|
||||
# whole window smoke 28 passed, 49 failed, 4 skipped of 81 before and after, the same tests; sdk/ui 60 tests.
|
||||
# Not read by the hit tests: a transform on a box between a z-indexed child and its stacking-context root (the
|
||||
# painter's clips don't read it either); in sdk/ui, an absolute box whose containing block is above the clipper.
|
||||
|
||||
@done
|
||||
Scenario: FT1a. A press outside the canvas never reaches it, at any zoom
|
||||
Given an ask with four pictures open on its canvas (React Flow), zoomed all the way in (scale 2)
|
||||
Then no point outside the canvas's box finds a piece of the canvas (document.elementFromPoint)
|
||||
And a press on the sidebar, the workspace picker or the header goes to what is drawn there
|
||||
And the canvas clips what it draws at its own box
|
||||
|
||||
@done
|
||||
Scenario: FT1b. A box that clips takes no pointer for what it cuts away, anywhere in the window
|
||||
Given a box with overflow other than visible, and a child that overflows it, with or without its own z-index
|
||||
Then a point outside the box's padding box never hits the child or anything in it
|
||||
But a fixed box, and a box whose containing blocks are above the clipping box, are not cut by it
|
||||
|
||||
Rule: FT2. The agents button is a checkbox that opens the to-do list
|
||||
# Status 11-13: built, in 0.1.3: raea-feed #12, merged ab68f0d (3b2353b, a2dc439). src/feed/todo.ts (the rows),
|
||||
# src/feed/TodoPanel.tsx, brief/format.ts removeTask and moveTask. The Agents panel and its menu surface are gone.
|
||||
# Checked: e2e/todo.spec.ts 4 of 4 in Chrome and 4 of 4 in the window; vitest (todo.test.ts, format.test.ts).
|
||||
# Decisions made here, each open to Shane's word:
|
||||
# - It is the tasks the app already has, not a second list: the project's brief's tasks (## Tasks in brief.md:
|
||||
# what the composer, the Board and agents write) and the edits sent on its items (comment tasks). Nothing is
|
||||
# kept by the list.
|
||||
# - Words are changed in a task's details (one click away, in the same column), not in the list's line: a click
|
||||
# on a line opens it, so the line itself stays a single target.
|
||||
# - A task's comments: an edit's replies; a brief task's are its linked item's open comments. A brief's task has
|
||||
# nowhere of its own to keep a comment yet.
|
||||
# - In the Inbox a new task goes to the project picked beside the line (the first, until picked).
|
||||
# - Reorder is within a project's brief tasks; an edit keeps its place by when it was sent.
|
||||
# Left: no keyboard shortcut opens the list; the Board's card sheet still edits a task's agents, due date and tags.
|
||||
|
||||
@done
|
||||
Scenario: FT2a. Where the agents button was, in a feed and in the Inbox
|
||||
Then a feed's header has no agents button; a checkbox there opens the to-do list in a column on the right
|
||||
And in a project's feed it is the project's list; in the Inbox the workspace's, each project's tasks under its name
|
||||
And its tooltip says what it is; the column closes from its own button and is as it was left next time
|
||||
|
||||
@done
|
||||
Scenario: FT2b. Minimal, skimmable
|
||||
Then a task is one line: a checkbox, its words, and who has it when someone does
|
||||
And its handle and Remove show only on the line pointed at or focused
|
||||
And done tasks are folded away under a count ("2 done"), opened by a click
|
||||
|
||||
@done
|
||||
Scenario: FT2c. Edited where it is read, written at once, with Undo
|
||||
When I type a line and press Enter, check a task off, change its words, drag it by its handle (or Alt+Up/Down),
|
||||
or remove it
|
||||
Then the change is written at once to where the task lives (the brief; a linked item's status; the comment)
|
||||
And Undo at the column's foot, or Cmd+Z, takes the last change back
|
||||
But a brief's change is undone only while the brief is still as that change left it
|
||||
|
||||
@done
|
||||
Scenario: FT2d. A click opens a task's details; Esc goes back
|
||||
Then the details show its words, who is on it and what they last did, the feed item it is linked to, its comments
|
||||
And an agent at work on it in one of the app's own sessions can be stopped there, with its subagents listed
|
||||
And Esc goes back to the list, not out of the feed
|
||||
|
||||
Rule: FT3. A session started outside the app is in the feed while it is open
|
||||
# Status 11-13: built, in 0.1.3: raea-feed #12, merged ab68f0d (7e90a7c, a2dc439). host/outside.ts (POST
|
||||
# /host/outside), src/feed/outside.ts, OutsideKeeper.tsx, OutsideBubble.tsx. No feed tool was added or changed.
|
||||
# Checked: e2e/outside.spec.ts 2 of 2 in Chrome and in the window (the host's list given by the spec);
|
||||
# host/outside.test.ts on files written as Claude Code writes them; the reader run against this Mac's six real
|
||||
# sessions. Not checked: a real session ending while the app's own window is watched by a person.
|
||||
# The signal, the smallest honest one: what the harness already keeps. Nothing new is asked of any session.
|
||||
# - Claude Code keeps ~/.claude/sessions/<pid>.json for each open session ({pid, sessionId, cwd, name, status})
|
||||
# and its transcript, <sessionId>.jsonl in its projects folder.
|
||||
# - active: its file is there, its process is alive, and a person runs it (kind "interactive"). Holding a claim
|
||||
# alone is not active: a task a session has that has ended still names it, without a live mark.
|
||||
# - working: the file says "busy"; otherwise it is open and waiting at its prompt.
|
||||
# - an update: its last words, the tool call at hand, its plan (the last TodoWrite), read from the transcript's
|
||||
# end; an item it posts and a task it marks are already in the feed and on the task.
|
||||
# - ended: the host no longer lists it.
|
||||
# Left: Codex, Gemini, Kimi and the rest keep no file that says a session is open, so they are in the feed only
|
||||
# by what they post; a session working in a folder that is no project's and that has posted nothing is in no
|
||||
# feed (Shane's own lanes in ~/raea are this case until they `raea show` something); rask claims and the lanes
|
||||
# board are not read.
|
||||
|
||||
@done
|
||||
Scenario: FT3a. One bubble a session, in the projects it is in
|
||||
Given a Claude Code session open on this Mac
|
||||
Then it has one bubble in the feed of each project whose folder it works in or that it has posted to
|
||||
(its posts carry its inbox, claude-code-<the first 8 of its id>, as `raea show` names it), and in the Inbox
|
||||
And a session that is in no project's folder and has posted nothing is in no feed
|
||||
|
||||
@done
|
||||
Scenario: FT3b. It reads as the app's own sessions do, without a Stop
|
||||
Then the bubble says its name and harness, that it is working (and for how long) or waiting at its prompt,
|
||||
the step at hand, its last words, and its plan
|
||||
And there is no Stop: a mark beside its status says where it runs and that it is stopped there
|
||||
|
||||
@done
|
||||
Scenario: FT3c. Its updates come as it goes, and it ends when the session does
|
||||
When it says something new or starts another step
|
||||
Then the same bubble shows it within a few seconds, written only when what it shows has changed
|
||||
When the session is no longer open
|
||||
Then the bubble ends, its last words kept; a session that comes back opens it again
|
||||
|
||||
@done
|
||||
Scenario: FT3d. It ties to the to-do list
|
||||
Then a brief's task that @names the session, and an edit on an item it posted, are its tasks
|
||||
And the bubble names them, and the to-do list shows the session on them with what it last did
|
||||
@@ -438,7 +438,7 @@ Feature: Fingerprint: a person's or a team's sense of good work, learned on thei
|
||||
feed with the fingerprint that judges it, asks first where a head goes against the person's own label on that
|
||||
moment, then where a head sits nearest its flag, one per axis and piece within 4 s, at most ten, as Yes/No
|
||||
questions in one `raea show` item with the moment cut to a clip; `--tally` makes each answer a "postmortem" row,
|
||||
retrains and prints each head's held-out AUC before and after. Archiving a project runs it in the background (raea-feed PR #5, not merged yet)
|
||||
retrains and prints each head's held-out AUC before and after. Archiving a project runs it in the background (raea-feed #5, in the 0.1.2 app)
|
||||
|
||||
Rule: FP8. Teams
|
||||
@needs:FP2d @done
|
||||
@@ -533,7 +533,7 @@ Feature: Fingerprint: a person's or a team's sense of good work, learned on thei
|
||||
notes' rows. `move [--fp CHILD] [--to PARENT] --axis/--source/--project` takes the child's own matching rows up
|
||||
into a fingerprint it extends and retrains both; rows on an axis the parent lacks or the child overrides stay
|
||||
|
||||
@needs:FP14c
|
||||
@needs:FP14c @done
|
||||
Scenario: FP14e. Managing them in the app
|
||||
Then the fingerprint page lists the person's fingerprints as a tree by `extends`, each with its `about`, where it
|
||||
applies, its labels and what it knows; one is shown at a time, and a project's page names the one judging it
|
||||
@@ -546,8 +546,10 @@ Feature: Fingerprint: a person's or a team's sense of good work, learned on thei
|
||||
Settings makes one the default and trains it; headless, the app made client-ads from me in 34 s and trained it
|
||||
from 12 renders in 3m54s (910 rows, 6 axes gating). Since: the switcher is a tree by `extends`, each saying
|
||||
which kinds and tags it judges; "New fingerprint" asks which it judges (`new --kinds --tags`); a project's header
|
||||
names the one `raea fingerprint which` picks, why in its tooltip. Not yet: making one in a project's or
|
||||
workspace's folder from the app (`share` does it from the CLI)
|
||||
names the one `raea fingerprint which` picks, why in its tooltip. 11-13 (raea-feed #8): that name is a menu
|
||||
saying who judges and why, with Keep with this project and Keep with the workspace listing the person's
|
||||
fingerprints; the host runs `share` and `use` there and commits the folder in the repo that holds it.
|
||||
Tests: host/fingerprint-keep.test.ts (the real raea in a throwaway home), e2e/fingerprint-keep.spec.ts
|
||||
|
||||
Rule: FP9. Agents use it, and can't game it
|
||||
@needs:FP3a,FP4b,FP5c
|
||||
@@ -594,14 +596,22 @@ Feature: Fingerprint: a person's or a team's sense of good work, learned on thei
|
||||
followed it left across the frame, a looser box (overlap 0.41). A blind seed in the middle of an app render
|
||||
kept only the note's frame, so only its own window
|
||||
|
||||
@needs:FP11b
|
||||
@needs:FP11b @done
|
||||
Scenario: FP11c. Marks on the sound
|
||||
Given the review player shows a sound's spectrogram under its picture (or in its place, for sound alone)
|
||||
Then a box drawn on it is a note's mark there, kept in 0-1 of the span shown (time) and of the frequencies (mel)
|
||||
And on a defect note on a sound axis, `learn-notes` makes its time the label's span and keeps its band in the row
|
||||
And decided 11-12: not in 0.1.2. The player draws no spectrogram, and raea-feed is fixed at what 0.1.2 ships.
|
||||
Until then a sound note's span (FP11a) is its time label, and the sound heads are per window, so a band
|
||||
would be kept but not yet learned from
|
||||
And decided 11-12: not in 0.1.2; built 11-13 for 0.1.3 (raea-feed #9). The host draws a mel
|
||||
spectrogram (host/spectrum.ts: 22.05 kHz, 64 bands to 11.025 kHz, a column every 25 ms, the loudest 80 dB),
|
||||
the timeline's sound track offers it as Spectrogram (opened tall), and Listen shows it under the waveform.
|
||||
A box dragged on it (with the Comment tool on the timeline, any drag in Listen) opens the moment card naming
|
||||
its span and band in Hz; the note's pin is a time pin over the box's span with one mark {kind: "box", on:
|
||||
"sound", points: [[time, mel], [time, mel]]} in 0-1 of the piece and of the mel scale, drawn again on the
|
||||
spectrogram in its author's hue, and the agent reads it as "Marked on the sound (box, T0 to T1, LO to HI)"
|
||||
(e2e/sound-marks.spec.ts, src/detail/marks.test.ts, host/spectrum.test.ts). `marked` ignores a sound box (it
|
||||
is no place in the frame); `sound_band` reads its band into the reading, and `learn-notes` labels t..to
|
||||
(widened to half a second about its middle when shorter) and keeps a defect's band in the evidence row's
|
||||
`band`. The sound heads are still per window, so the band is kept but not yet learned from
|
||||
|
||||
Rule: FP12. Heatmaps: a picture axis says where, not only whether
|
||||
@needs:FP11b,FP2c @done
|
||||
|
||||
@@ -31,6 +31,95 @@ Feature: Lightspeed: raea as fast as anything could be, with the best quality, m
|
||||
And it updates the row here (value, date, commit) and appends a line to the log at the bottom
|
||||
And when an experiment doesn't pay, it records the numbers and reverts the change. A measured no is a result
|
||||
|
||||
Rule: 0.1.4, the performance release (set 2026-11-13: "the v0.1.4 update will be completely performance based")
|
||||
# Seven areas, each with a measured baseline before anything changes. Measured on a clone of a real workspace (9
|
||||
# projects, 21,713 files, a 19 GB media library), the built app headless, a Mac with 64 GB.
|
||||
Scenario: PF1. App start and data loading: seconds if not milliseconds
|
||||
Then the baseline, warm, headless: projects listed 0.61 to 0.67 s after the app is spawned (its host up at
|
||||
0.45 to 0.5 s); a project's feed shown 136 ms after the click with 6 cards, 260 to 282 ms with 41 (about 6 ms
|
||||
a card)
|
||||
And the largest real project's feed (93 cards): its first card 215 ms after the click, settled at 320 ms
|
||||
And the first launch after a new binary: 3.7 s to the projects listed (0.6 s warm)
|
||||
And open: a cold start after a reboot, the window on screen, and a feed of several hundred cards
|
||||
|
||||
Scenario: PF2. Thumbnails: feed items, the library, a project's Source
|
||||
Then a composition's still is `raea play FILE --offscreen --seek N` in a process of its own, two at a time:
|
||||
1.4 s, 1.9 s and 5.0 s for three real compositions (a ray-traced set is the 5 s one)
|
||||
And fixed (raea #141): beside a tsconfig.json, which raea writes into every new project, that play threw before
|
||||
its first frame, so every still there was a failed play and then a render (as slow, and the app's stage and
|
||||
`raea play` did not work at all in such a folder)
|
||||
And faster with PF4's start (raea #147): the same three stills 0.5 s, 1.2 s and 1.2 s warm, and one of the
|
||||
largest project that took 4.05 s as a one-frame render 0.63 s played
|
||||
And open: stills drawn in one long-lived process instead of one each (each pays the engine's start), and the
|
||||
library's tiles on a real library (the test copy has none)
|
||||
|
||||
Scenario: PF3. Video takes the space it needs, no more
|
||||
Then the baseline: 38 GB of video in 1,010 files on this Mac, most at 90 to 100 Mbit/s for 1080p, because every
|
||||
review version and every shot to be joined was rendered at `--quality master`
|
||||
And measured on 1080p24 film footage: default 16 Mbit/s, high 30, master 87; against the master encode the
|
||||
default scores VMAF 99.5 (worst frame 95.8) and high 99.7
|
||||
And fixed in the guides and the skill (raea #143, raea-skills #59, pinned 16ed215): a version made for notes
|
||||
takes no --quality flag, a film delivers at high, master is for delivered motion graphics and type, a
|
||||
replaced version is deleted
|
||||
And open: the app saying what renders take and offering to make old versions smaller; whether the library's
|
||||
copy of a render posted from a project is a clone of it or a second file
|
||||
|
||||
Scenario: PF4. Renders two to three times faster
|
||||
Then the baseline on a real ray-traced film at 1080p: a 61-frame shot is 5.2 to 5.8 s, of which the frames are
|
||||
about 2.2 s (25 to 30 a second: 18 to 20 ms waiting on the GPU and 14 to 22 ms making the frame's rows in
|
||||
JavaScript, one after the other) and the rest is the process starting; the whole 1,666-frame film is 53 s
|
||||
And the two levers that follow from it: a frame's rows made while the GPU draws the one before (they are
|
||||
independent: about 1.5 to 2 times on the frames), and every composition of a file rendered in one process (a
|
||||
film made a shot at a time pays about 3.3 s a shot for nothing: 33 shots, 110 s)
|
||||
And fixed (raea #144): a ray-traced camera's MSAA was turned on again every frame and off again by Bevy with a
|
||||
warning, a line a frame in the render's log
|
||||
And fixed (raea #147), the start: before its first frame a render read the first and last MiB of every picture,
|
||||
sound and video under the edit's folder (to ask for an optimized copy only a video has) and walked the whole
|
||||
folder, .git and node_modules included, for imports from outside it. Time to the first frame of an .mp4, bundle
|
||||
cached: 2.0 s to 0.35 s in a project of 1,234 files, 7.4 s to 0.62 s in one of 10,226; a 60-frame shot 4.7 s
|
||||
to 3.0 s end to end
|
||||
And measured since, what the frames themselves are: flat 2D at 1080p is 254 frames a second with no wait on the
|
||||
GPU; a ray-traced 1080p frame is 18 to 20 ms of GPU and about 5 ms of the scene's sync, so a long ray-traced
|
||||
render is the GPU's. Four ray-traced shots side by side take 7.4 s where in turn they take 11.3 (1.5 times),
|
||||
each frame two to three times slower: the GPU is one, and the window and every other render wait on it, so
|
||||
it is not a default. Two to three times on ray-traced frames is a cheaper trace (fewer pixels or samples
|
||||
traced, then upscaled), which changes the picture and is a rendering decision, not plumbing
|
||||
|
||||
Scenario: PF5. What agents lose time on
|
||||
Then fixed in the lane check (tools/agents/check, on this Mac): the CLI surface step tests the raea it rebuilds
|
||||
(it tested an older build on PATH, and stayed failing after its own rebuild), and the skills step reads the feed
|
||||
app at raea-feed's main (it read whatever branch the shared checkout had out): a lane's check now passes with
|
||||
no variables set
|
||||
And fixed (raea #141, in 0.1.3): `raea play` beside a tsconfig.json, which every new project has
|
||||
And fixed in the app (raea-feed #13, not merged): a review sent on an item whose author is named over a
|
||||
connection went to an inbox it doesn't have, so its edits waited for good; and an agent whose session isn't
|
||||
open is started again by the send
|
||||
And open, each seen on 2026-11-13: a render with <Audio> that reaches no sound is refused only after every frame
|
||||
is drawn (53 s on a film; what sounds are known only once the frames are made); `-o DIR` writes every frame
|
||||
as a PNG (4.9 GB for a film) with nothing said of its size; `but commit` with a long message commits nothing
|
||||
and says so only in a hint; main can fail its own L1 after a GitHub merge (two stale generated pages blocked
|
||||
every lane for a morning)
|
||||
And a release's builds, about three hours each and run many times, moved to larger runners with a cache volume
|
||||
and a compile cache: a candidate after a small change should take minutes (the release lane's; rc4 and rc5
|
||||
are the first measured)
|
||||
|
||||
Scenario: PF6. Video playback and looking around a scene
|
||||
Then video (raea #137): frames decoded a quarter second ahead and shown when due, a faster pixel conversion, a
|
||||
small-drawn video drawn from a halving made off the page's thread: 4K30's worst wait between frames 76 ms to
|
||||
39, 4K60 on a page drawing 120 times a second 0 of 1,214 frames passed over
|
||||
And the app's player (raea-feed #13, not merged): the detail view's clock is outside React state, so a playing
|
||||
video's ticks render only what shows the time: the seconds of 60 fps play with a wait of 26 ms or more
|
||||
between frames go from nearly all to about half
|
||||
And open: frames still go through the CPU; the scene inspector's frame rate while orbiting is not measured
|
||||
|
||||
Scenario: PF8. Pages and assets from this Mac open at once
|
||||
Then covered so far by PF1 (a feed) and PF2 (stills)
|
||||
And a project's Source view (50 compositions, 71 components): its list is there 0.18 s after the click when
|
||||
its thumbnails are in the proxy store, and 2.4 to 3.8 s when the store is empty and the feed's own are still
|
||||
being made. Not explained: the host answers in 0.25 to 0.33 s, the window draws 47 to 91 frames a second
|
||||
throughout, holding still-drawing at the click changes nothing, and so does asking for no row thumbnails
|
||||
And open: that first visit; an asset's preview, a model's, and the library on a real library
|
||||
|
||||
Rule: Lightspeed's goals (set 2026-10-19, after the four multi-day levers; the user: "just focus on lightspeed work")
|
||||
Scenario: Who owns what now
|
||||
Then lightspeed owns performance and optimization end to end: it builds its levers itself, not only measures them
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
title: "Check a cut with it"
|
||||
summary: "Score a cut with your fingerprint before it's posted, check that a fix removed a flag instead of hiding it, judge scripts and stills, find things floating in a 3D shot, and compare a cut with work you admire."
|
||||
order: 2
|
||||
sources: ["docs/fingerprint.feature", "apps/fingerprint/src", "systems/fingerprint-use/src", "systems/fingerprint-things/src"]
|
||||
---
|
||||
|
||||
## Score a cut
|
||||
|
||||
```sh
|
||||
raea fingerprint score out/cut.mp4 # the moments it expects a note on, first
|
||||
raea fingerprint score out/cut.mp4 --sheet cut.png # the same on a sheet of frames, with where boxed
|
||||
raea fingerprint score out/cut.mp4 --timeline # the piece second by second, in words
|
||||
raea fingerprint which out/cut.mp4 # which fingerprint judged it, and why
|
||||
```
|
||||
|
||||
`score` names which fingerprint judged the piece, then lists the moments it expects a note on, each in your words. On
|
||||
a picture axis that has learned where, a moment also says where in the frame and, on a render with a layer pass, the
|
||||
layers there ("top right on Floor"). `--json` gives every axis for every window, for a script.
|
||||
|
||||
An axis that **knows** can hold a post back until you've looked. One that is **learning** only advises. Your agents
|
||||
run `score` before they post, fix each moment that holds the cut back, or tell you why they didn't.
|
||||
|
||||
## Check a fix
|
||||
|
||||
```sh
|
||||
raea fingerprint score out/v2.mp4 --was out/v1.mp4
|
||||
```
|
||||
|
||||
For each moment that held v1 back, this says whether v2 fixed it, still has it, or looks **disguised**: nearer the
|
||||
axis's disguised defects than clean work, so the fix hid the defect instead of removing its cause. Only a fixed flag
|
||||
counts as fixed.
|
||||
|
||||
## Scripts, briefs and stills
|
||||
|
||||
A fingerprint reads more than video. A script, a brief or another text file gets EmbeddingGemma 2 rows, one per
|
||||
paragraph, and a still gets the picture columns. Each axis judges only what the file has, so a script is never called
|
||||
blurry. raea's own axes judge pictures, sound and motion. To judge writing, add an axis that reads text to your
|
||||
fingerprint.ts and teach it like any other.
|
||||
|
||||
## Things in a shot
|
||||
|
||||
```sh
|
||||
raea render shot.tsx --layers -o shot.mp4 # the video and its layers (shot.layers)
|
||||
raea render shot.tsx --aov -o shot.aov # its depth, beside it
|
||||
raea fingerprint things shot.mp4 --json > things.json
|
||||
raea check shot.mp4 --things things.json
|
||||
```
|
||||
|
||||
`things` finds a piece's shots, the things in each (a render's layers, and anything marked on its notes) with their
|
||||
depth, and the camera's path. It says where a thing floats, where two pass through each other, where the camera lurches
|
||||
in the middle of a move, and where nothing is on screen. `raea check --things` turns those into findings beside the
|
||||
rest. Floating needs real depth: with the render's `--aov` pass beside it (`shot.aov` for `shot.mp4`) it uses the
|
||||
render's own depth, and without one it estimates depth from the picture, which can't always tell a hanging box from
|
||||
one on the floor.
|
||||
|
||||
## Profiles of work you admire
|
||||
|
||||
```sh
|
||||
raea fingerprint profile golden/*.mp4 --as reels --against others.txt
|
||||
raea fingerprint score cut.mp4 --profile reels
|
||||
```
|
||||
|
||||
A profile takes the ranges your references span: loudness, bass against treble, cuts a minute, motion, brightness,
|
||||
contrast, saturation and sharpness. A cut scored against it hears which measures fall outside, where, and which way
|
||||
to move. The profile checks itself: each reference has to fit the others' ranges more often than unrelated work does,
|
||||
or raea says it doesn't tell this taste apart.
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
title: "Fingerprint: teach raea your eye"
|
||||
summary: "What raea learns about good work from your notes, marks and approvals, on your Mac: the axes it judges, the Fingerprint page, and what it can't judge yet."
|
||||
order: 0
|
||||
sources: ["docs/fingerprint.feature", "docs/fingerprint.md", "apps/fingerprint/src", "systems/fingerprint/src", "systems/fingerprint-use/src", "apps/app/src/fingerprint"]
|
||||
---
|
||||
|
||||
A fingerprint is your sense of good work, as raea has learned it on your Mac. It's a list of axes, the things you
|
||||
notice: blur, a black frame, hiss, clipping, a glow over everything, a frozen picture, and taste axes such as fake,
|
||||
barren or unreadable text. Each axis has a small model over encoders that run on your Mac (SigLIP 2 for pictures, CLAP
|
||||
for sound, YAMNet for sound events, EmbeddingGemma 2 for scripts and other text), so nothing leaves the machine unless
|
||||
you share it.
|
||||
|
||||
Your agents use it before they post a cut: `raea fingerprint score` lists the moments your fingerprint expects a note
|
||||
on, each named in your words, and the agent fixes them or tells you why it didn't. It tells you the axis and the
|
||||
moment, never a number.
|
||||
|
||||
## In this section
|
||||
|
||||
- [Train your fingerprint](train.md): learning from your own renders, your notes and marks, a box on the part of a
|
||||
sound you mean, and a post-mortem when a project is done.
|
||||
- [Check a cut with it](check.md): scoring a cut, checking a fix, scripts and stills, things in a shot, and profiles
|
||||
of work you admire.
|
||||
- [Projects and teams](projects.md): one fingerprint for each kind of work, which one judges a project, keeping one
|
||||
with a project or workspace, and sharing with a team.
|
||||
|
||||
## The Fingerprint page
|
||||
|
||||
Open **Fingerprint** in the sidebar. The card at the top is your mark, one column of bits for each axis, grouped by
|
||||
sense: pictures, sound and motion. Point at a sense to see its axes and how well each one judges. Below it, every axis
|
||||
says whether it **knows** (it's trusted, and can hold a post back until you've looked), is **learning** (it gives
|
||||
advice), or is still **to learn** (it only has its words). **Can't judge yet** lists what no axis can see, such as
|
||||
whether a piece works as a whole.
|
||||
|
||||
The name in the page's title is a menu of your fingerprints. **Settings** holds what one is for, what it builds on,
|
||||
whether it's your default, and **Learn from renders**.
|
||||
|
||||
A fingerprint's axes are a file you can read and edit, `~/.raea/fingerprints/NAME/fingerprint.ts`, typed by
|
||||
`raea/fingerprint` ([the SDK page](../reference/sdk/fingerprint.md)). Add, remove or reword an axis there; its
|
||||
evidence is raea's to keep. Every command is on [the CLI page](../reference/cli/fingerprint.md).
|
||||
|
||||
## What it can't do yet
|
||||
|
||||
Axes judge two-second moments, so a fingerprint can't say whether a piece works as a whole, or judge story and pace
|
||||
across shots. It can say where in the frame only for blur, glitches and flat, barren surfaces; glow it can only
|
||||
flag. Sound axes judge the whole sound in each moment, so a box's pitch band is kept but not yet learned from. A
|
||||
stylised look or a held shot can read as a defect. And taste axes with only words never hold a post back.
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
title: "Projects and teams"
|
||||
summary: "One fingerprint for each kind of work, which one judges a project and why, keeping one with a project or its workspace from the app, and sharing one with a team."
|
||||
order: 3
|
||||
sources: ["docs/fingerprint.feature", "apps/fingerprint/src", "apps/app/src/fingerprint", "apps/app/host/fingerprint.ts"]
|
||||
---
|
||||
|
||||
## One for each kind of work
|
||||
|
||||
You can keep several fingerprints, each saying what it's for. One can build on another: a client's ads can start from
|
||||
your own and add what that client cares about. It inherits your axes and evidence, counts its own labels twice, and
|
||||
never changes yours.
|
||||
|
||||
```sh
|
||||
raea fingerprint new client-ads --about "Short ads for one brand: pace, type on screen" --extends me
|
||||
```
|
||||
|
||||
## Which one judges a project
|
||||
|
||||
Which one judges a piece is decided by where it lives: the project's fingerprints first, then the workspace's, then
|
||||
your own. At each level, the one whose `applies` matches the piece's kind wins, else that level's default.
|
||||
|
||||
In the app, a project's feed names it beside the project's name at the top: the fingerprint chip. Open it to see which
|
||||
fingerprint judges the project and why. When it's one of yours, **Open** takes you to its Fingerprint page. The chip
|
||||
shows once you have a fingerprint.
|
||||
|
||||
From a terminal:
|
||||
|
||||
```sh
|
||||
raea fingerprint which projects/brand/out/cut.mp4 # which one judges this, and why
|
||||
```
|
||||
|
||||
## Keep one with a project
|
||||
|
||||
The chip's menu has **Keep with this project** and **Keep with the workspace**. Pick one of your fingerprints under
|
||||
either and raea copies it into that folder and commits it, so it travels with the folder's repository: everyone on
|
||||
the team judges the project with the same taste, and the chip names it from then on.
|
||||
|
||||
The same from a terminal:
|
||||
|
||||
```sh
|
||||
raea fingerprint share client-ads --in project projects/brand # copy it into the project
|
||||
raea fingerprint use client-ads --in project projects/brand # and make it the one that judges there
|
||||
```
|
||||
|
||||
Use `--in workspace` for every project in the workspace.
|
||||
|
||||
## Sharing with a team
|
||||
|
||||
Sharing copies the axes and the evidence (embeddings, spans and labels) into the workspace or project, to travel with
|
||||
its repository. It never shares media or trained weights: each teammate's Mac trains its own from everyone's
|
||||
evidence, and each person's evidence sits in its own folder so two people labelling at once never edit the same
|
||||
file. When raea's encoders change, `raea fingerprint reembed FOLDER` moves the evidence to the new ones wherever it
|
||||
finds the media.
|
||||
|
||||
```sh
|
||||
raea fingerprint diff me ana # where two tastes differ, and the moments that show it
|
||||
```
|
||||
|
||||
## Notes teach the one that judged
|
||||
|
||||
Your notes and marks on a piece teach the fingerprint that judged it, so a client's notes stay with the client's
|
||||
fingerprint. When one of its lessons is really yours, move it up:
|
||||
|
||||
```sh
|
||||
raea fingerprint move --fp client-ads --axis glow # its glow labels become yours (me)
|
||||
```
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: "Train your fingerprint"
|
||||
summary: "Teach a fingerprint from your own renders, your notes, marks and approvals, a box on the part of a sound you mean, and a post-mortem when a project is done; and when it trusts an axis."
|
||||
order: 1
|
||||
sources: ["docs/fingerprint.feature", "apps/fingerprint/src", "systems/fingerprint/src", "apps/app/src/fingerprint"]
|
||||
---
|
||||
|
||||
A new fingerprint judges from the words for each axis on day one. Everything after that is evidence: your own work,
|
||||
and what you say about it.
|
||||
|
||||
## From your renders
|
||||
|
||||
To train the mechanical axes, choose **Learn from renders** in the Fingerprint page's Settings, or run:
|
||||
|
||||
```sh
|
||||
raea fingerprint bootstrap ~/renders/*.mp4
|
||||
```
|
||||
|
||||
raea damages moments of your own finished work on purpose (a blur, a black frame, a gap in the sound) and learns the
|
||||
difference, held out by source, so it can't learn a shortcut. Each axis also has disguised versions of its defect, such
|
||||
as a blur that was sharpened afterwards or a freeze hidden under a slow zoom. An axis that misses its disguises stays
|
||||
advice.
|
||||
|
||||
The same run teaches picture axes where a defect sits. It blurs, punches a hole in, greys out or glows one patch of a
|
||||
frame, and learns to find the patch. An axis that finds it 85 times in 100 on renders it didn't learn from says where:
|
||||
`score` then gives the moment's place in the frame, such as "top right", and on a render with a layer pass the layers
|
||||
there, such as "on Floor", and `--sheet` boxes it on the frame.
|
||||
|
||||
## From your reviewing
|
||||
|
||||
Your own reviewing teaches it the rest:
|
||||
|
||||
```sh
|
||||
raea fingerprint teach cut.mp4 --axis blur --at 4.2 --bad # a moment you marked
|
||||
raea fingerprint approve final.mp4 # approved work is clean, except where you left a note
|
||||
raea fingerprint pair v1.mp4 v2.mp4 --axis glow # v2 is better on glow
|
||||
raea fingerprint read projects/stay # read your pinned notes into labels
|
||||
raea fingerprint readings --ask 50 # check 50 of those readings in the app
|
||||
raea fingerprint learn-notes projects/stay # once they read right, your notes become evidence
|
||||
```
|
||||
|
||||
Notes become evidence only after you've checked how they were read: the kind right 45 times in 50 and the axis 40. A
|
||||
note that asks for a creative change goes to the brief, never into an axis. Each project's notes teach the
|
||||
fingerprint that judges that project ([Projects and teams](projects.md)).
|
||||
|
||||
## Point at what you mean
|
||||
|
||||
A note can say exactly what it's about. On the picture, drop a pin and mark, box or lasso the thing you mean.
|
||||
|
||||
On the sound, choose **Spectrogram** on the timeline's sound track (or open the sound in Listen) and, with the Comment
|
||||
tool, drag a box around the part you mean, such as a hiss up high or a hum down low. A sound on its own shows its
|
||||
spectrogram under the waveform, where any drag draws a box. The note keeps the box's time as its span and its pitch
|
||||
band, your agent reads both with the note, and `learn-notes` labels that span and keeps the band in the label. Sound
|
||||
axes still judge the whole sound in each moment, so the band is kept but not yet learned from.
|
||||
|
||||
## When an axis is trusted
|
||||
|
||||
An axis is trusted once it has 16 labels of each kind from 3 projects, ranks real defects above clean work on
|
||||
projects it never saw, and catches its disguises. `raea fingerprint report` says where each one stands. An axis that is
|
||||
still under its bar with 300 labels is **stuck**: more labels won't help it, so `report` names it as one to try on
|
||||
another encoder.
|
||||
|
||||
## Looking back on a project
|
||||
|
||||
When a project is done, a post-mortem asks you what the fingerprint is least sure of:
|
||||
|
||||
```sh
|
||||
raea fingerprint postmortem projects/film # at most ten yes/no questions in the app, each with its moment
|
||||
raea fingerprint postmortem projects/film --tally # your answers become evidence; each head's score before and after
|
||||
```
|
||||
|
||||
It scores every version in the project's feed and first asks where a head disagrees with a label you gave on that
|
||||
moment, then where a head is nearest its flag, one question per axis within four seconds.
|
||||
@@ -1,150 +0,0 @@
|
||||
---
|
||||
title: "Fingerprint: teach raea your eye"
|
||||
summary: "What raea learns about good work from your notes, marks and approvals, on your Mac: the axes it judges, how one is trained and trusted, keeping one fingerprint for each kind of work, and sharing one with a team."
|
||||
order: 6
|
||||
sources: ["docs/fingerprint.feature", "docs/fingerprint.md", "apps/fingerprint/src", "systems/fingerprint/src", "systems/fingerprint-use/src", "systems/fingerprint-things/src", "apps/app/src/fingerprint"]
|
||||
---
|
||||
|
||||
A fingerprint is your sense of good work, as raea has learned it on your Mac. It's a list of axes, the things you
|
||||
notice: blur, a black frame, hiss, clipping, a glow over everything, a frozen picture, and taste axes such as fake,
|
||||
barren or unreadable text. Each axis has a small model over encoders that run on your Mac (SigLIP 2 for pictures, CLAP
|
||||
for sound, YAMNet for sound events, EmbeddingGemma 2 for scripts and other text), so nothing leaves the machine unless
|
||||
you share it.
|
||||
|
||||
Your agents use it before they post a cut: `raea fingerprint score` lists the moments your fingerprint expects a note
|
||||
on, each named in your words, and the agent fixes them or tells you why it didn't. It tells you the axis and the
|
||||
moment, never a number.
|
||||
|
||||
## The Fingerprint page
|
||||
|
||||
Open **Fingerprint** in the sidebar. The card at the top is your mark, one column of bits for each axis, grouped by
|
||||
sense: pictures, sound and motion. Point at a sense to see its axes and how well each one judges. Below it, every axis
|
||||
says whether it **knows** (it's trusted, and can hold a post back until you've looked), is **learning** (it gives
|
||||
advice), or is still **to learn** (it only has its words). **Can't judge yet** lists what no axis can see, such as
|
||||
whether a piece works as a whole.
|
||||
|
||||
The name in the page's title is a menu of your fingerprints. **Settings** holds what one is for, what it builds on,
|
||||
whether it's your default, and **Learn from renders**.
|
||||
|
||||
## Training one
|
||||
|
||||
A new fingerprint judges from the words for each axis on day one. To train the mechanical axes, choose **Learn from
|
||||
renders**, or run:
|
||||
|
||||
```sh
|
||||
raea fingerprint bootstrap ~/renders/*.mp4
|
||||
```
|
||||
|
||||
raea damages moments of your own finished work on purpose (a blur, a black frame, a gap in the sound) and learns the
|
||||
difference, held out by source, so it can't learn a shortcut. Each axis also has disguised versions of its defect, such
|
||||
as a blur that was sharpened afterwards or a freeze hidden under a slow zoom. An axis that misses its disguises stays
|
||||
advice.
|
||||
|
||||
The same run teaches picture axes where a defect sits. It blurs, punches a hole in, greys out or glows one patch of a
|
||||
frame, and learns to find the patch. An axis that finds it 85 times in 100 on renders it didn't learn from says where:
|
||||
`score` then gives the moment's place in the frame, such as "top right", and on a render with a layer pass the layers
|
||||
there, such as "on Floor", and `--sheet` boxes it on the frame.
|
||||
|
||||
Your own reviewing teaches it the rest:
|
||||
|
||||
```sh
|
||||
raea fingerprint teach cut.mp4 --axis blur --at 4.2 --bad # a moment you marked
|
||||
raea fingerprint approve final.mp4 # approved work is clean, except where you left a note
|
||||
raea fingerprint pair v1.mp4 v2.mp4 --axis glow # v2 is better on glow
|
||||
raea fingerprint read projects/stay # read your pinned notes into labels
|
||||
raea fingerprint readings --ask 50 # check 50 of those readings in the app
|
||||
```
|
||||
|
||||
Notes become evidence only after you've checked how they were read: the kind right 45 times in 50 and the axis 40. A
|
||||
note that asks for a creative change goes to the brief, never into an axis. An axis is trusted once it has 16 labels of
|
||||
each kind from 3 projects, ranks real defects above clean work on projects it never saw, and catches its disguises.
|
||||
`raea fingerprint report` says where each one stands. An axis that is still under its bar with 300 labels is
|
||||
**stuck**: more labels won't help it, so `report` names it as one to try on another encoder.
|
||||
|
||||
## Scripts, briefs and stills
|
||||
|
||||
A fingerprint reads more than video. A script, a brief or another text file gets EmbeddingGemma 2 rows, one per
|
||||
paragraph, and a still gets the picture columns. Each axis judges only what the file has, so a script is never called
|
||||
blurry. raea's own axes judge pictures, sound and motion. To judge writing, add an axis that reads text to your
|
||||
fingerprint.ts and teach it like any other.
|
||||
|
||||
## Looking back on a project
|
||||
|
||||
When a project is done, a post-mortem asks you what the fingerprint is least sure of:
|
||||
|
||||
```sh
|
||||
raea fingerprint postmortem projects/film # at most ten yes/no questions in the app, each with its moment
|
||||
raea fingerprint postmortem projects/film --tally # your answers become evidence; each head's score before and after
|
||||
```
|
||||
|
||||
It scores every version in the project's feed and first asks where a head disagrees with a label you gave on that
|
||||
moment, then where a head is nearest its flag, one question per axis within four seconds.
|
||||
|
||||
## Things in a shot
|
||||
|
||||
```sh
|
||||
raea render shot.tsx --layers -o shot.mp4 # the video and its layers (shot.layers)
|
||||
raea render shot.tsx --aov -o shot.aov # its depth, beside it
|
||||
raea fingerprint things shot.mp4 --json > things.json
|
||||
raea check shot.mp4 --things things.json
|
||||
```
|
||||
|
||||
`things` finds a piece's shots, the things in each (a render's layers, and anything marked on its notes) with their
|
||||
depth, and the camera's path. It says where a thing floats, where two pass through each other, where the camera lurches
|
||||
in the middle of a move, and where nothing is on screen. `raea check --things` turns those into findings beside the
|
||||
rest. Floating needs real depth: with the render's `--aov` pass beside it (`shot.aov` for `shot.mp4`) it uses the
|
||||
render's own depth, and without one it estimates depth from the picture, which can't always tell a hanging box from
|
||||
one on the floor.
|
||||
|
||||
## One for each kind of work
|
||||
|
||||
You can keep several fingerprints, each saying what it's for. One can build on another: a client's ads can start from
|
||||
your own and add what that client cares about. It inherits your axes and evidence, counts its own labels twice, and
|
||||
never changes yours.
|
||||
|
||||
```sh
|
||||
raea fingerprint new client-ads --about "Short ads for one brand: pace, type on screen" --extends me
|
||||
raea fingerprint which projects/brand/out/cut.mp4 # which one judges this, and why
|
||||
raea fingerprint use client-ads --in project projects/brand
|
||||
```
|
||||
|
||||
Which one judges a piece is decided by where it lives: the project's fingerprints first, then the workspace's, then
|
||||
your own. At each level, the one whose `applies` matches the piece's kind wins, else that level's default.
|
||||
|
||||
Your notes and marks on a piece teach the fingerprint that judged it, so a client's notes stay with the client's
|
||||
fingerprint. When one of its lessons is really yours, move it up:
|
||||
|
||||
```sh
|
||||
raea fingerprint move --fp client-ads --axis glow # its glow labels become yours (me)
|
||||
```
|
||||
|
||||
## Profiles of work you admire
|
||||
|
||||
```sh
|
||||
raea fingerprint profile golden/*.mp4 --as reels --against others.txt
|
||||
raea fingerprint score cut.mp4 --profile reels
|
||||
```
|
||||
|
||||
A profile takes the ranges your references span: loudness, bass against treble, cuts a minute, motion, brightness,
|
||||
contrast, saturation and sharpness. A cut scored against it hears which measures fall outside, where, and which way
|
||||
to move. The profile checks itself: each reference has to fit the others' ranges more often than unrelated work does,
|
||||
or raea says it doesn't tell this taste apart.
|
||||
|
||||
## Sharing with a team
|
||||
|
||||
```sh
|
||||
raea fingerprint share studio --in workspace
|
||||
raea fingerprint diff me ana # where two tastes differ, and the moments that show it
|
||||
```
|
||||
|
||||
Sharing copies the axes and the evidence (embeddings, spans and labels) into the workspace or project, to travel with
|
||||
its repository. It never shares media or trained weights: each teammate's Mac trains its own from everyone's
|
||||
evidence, and each person's evidence sits in its own folder so two people labelling at once never edit the same
|
||||
file. When raea's encoders change, `raea fingerprint reembed FOLDER` moves the evidence to the new ones wherever it
|
||||
finds the media.
|
||||
|
||||
## What it can't do yet
|
||||
|
||||
Axes judge two-second moments, so a fingerprint can't say whether a piece works as a whole, or judge story and pace
|
||||
across shots. It can say where in the frame only for blur, glitches and flat, barren surfaces; glow it can only
|
||||
flag. A stylised look or a held shot can read as a defect. And taste axes with only words never hold a post back.
|
||||
@@ -44,6 +44,13 @@ The raea skill (`raea skill` prints it) is the short version of the same loop; t
|
||||
- [3D scenes](guides/3d.md): cameras, lights, meshes and materials in TSX, drawn by Bevy.
|
||||
- [Apps on the web target or native](guides/apps.md): a React file that runs as a desktop app.
|
||||
|
||||
## Fingerprint
|
||||
|
||||
- [Fingerprint: teach raea your eye](fingerprint/index.md): what raea learns about good work from your notes, on your Mac.
|
||||
- [Train your fingerprint](fingerprint/train.md): your renders, notes and marks, and a box on the part of a sound you mean.
|
||||
- [Check a cut with it](fingerprint/check.md): score a cut before it's posted, and check that a fix really fixed it.
|
||||
- [Projects and teams](fingerprint/projects.md): which fingerprint judges a project, and keeping one with it for the team.
|
||||
|
||||
## Reference
|
||||
|
||||
- [The CLI](reference/cli.md): a page for each of the 43 `raea` verbs, with its forms, where it runs and what each flag does.
|
||||
|
||||
@@ -323,7 +323,7 @@ function useSong(map: SongMap, options?: UseSongOptions): SongMoment & { song: S
|
||||
|
||||
### `useVideoConfig`
|
||||
|
||||
The settings of the composition being rendered (a Sequence's width and height win inside it).
|
||||
The settings of the composition being rendered (inside a Sequence, its width, height and length win).
|
||||
|
||||
```ts
|
||||
function useVideoConfig(): VideoConfig
|
||||
|
||||
@@ -72,7 +72,7 @@ function useLocalTime(caller: string): LocalTime
|
||||
|
||||
### `useVideoConfig`
|
||||
|
||||
The settings of the composition being rendered (a Sequence's width and height win inside it).
|
||||
The settings of the composition being rendered (inside a Sequence, its width, height and length win).
|
||||
|
||||
```ts
|
||||
function useVideoConfig(): VideoConfig
|
||||
@@ -115,6 +115,7 @@ The local time a subtree sees: its own frame, and the composition frame its fram
|
||||
| `origin` (required) | `number` | the composition frame the subtree's frame 0 falls on |
|
||||
| `width` (required) | `number` | width and height a Sequence overrides for its children |
|
||||
| `height` (required) | `number` | in px, what the Sequence gives its children |
|
||||
| `duration` (required) | `number` | frames the subtree runs for from its frame 0, which useVideoConfig reports as durationInFrames: a Sequence's own length cut where its parent's ends, a Loop's one pass, the composition's at the root |
|
||||
|
||||
### `Perception`
|
||||
|
||||
|
||||
@@ -62,6 +62,21 @@ curl -fsSL https://raea.io/install | sh
|
||||
|
||||
Then see what changed in [What's new](../whats-new/index.md).
|
||||
|
||||
### The desktop app
|
||||
|
||||
The desktop app looks for a newer raea when it starts and every six hours, and a card in the bottom right corner says
|
||||
when one is out. On the Mac, raea.app downloads and checks the update itself: press **Restart now**, or it switches the
|
||||
next time you quit. On Windows and Linux, **Download** gets the new build, and you install it over this one. Your
|
||||
projects and settings stay as they are.
|
||||
|
||||
To look for an update yourself, open **Settings → General** and press **Check for updates**. From 0.1.3, an update
|
||||
that is waiting also shows as **Update** at the foot of the sidebar.
|
||||
|
||||
On the Mac, drag raea.app into Applications before you open it. Opened straight from Downloads, macOS runs it from a
|
||||
read-only copy, and raea 0.1.1 and 0.1.2 can't replace themselves there: Restart now does nothing. If that happened to
|
||||
you, download raea from [raea.io/download/mac](https://raea.io/download/mac), drag it into Applications and open it
|
||||
from there. From 0.1.3, raea updates wherever it was opened from, and says so if it ever can't.
|
||||
|
||||
## Pick a version
|
||||
|
||||
Set `RAEA_VERSION` to install a particular release instead of the newest:
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: "raea 0.1.2"
|
||||
version: "0.1.2"
|
||||
date: "2026-11-13"
|
||||
summary: "Components that measure as they do in Chrome, a fingerprint of what you judge good, and one timeline for picture and sound in the app's player."
|
||||
sources: ["https://github.com/shinyobjectz/raea/releases/tag/v0.1.2"]
|
||||
---
|
||||
|
||||
raea 0.1.2 lets compositions measure themselves the way a web page does, teaches raea what you judge good, and gives the app's player one timeline for picture and sound.
|
||||
|
||||
**Get the app at [raea.io](https://raea.io)** (a Mac with Apple silicon, Windows 10 or 11, or Linux on x86_64).
|
||||
|
||||
The engine alone:
|
||||
|
||||
```sh
|
||||
curl -fsSL https://raea.io/install | sh
|
||||
```
|
||||
|
||||
On Windows, in PowerShell: `irm https://raea.io/install.ps1 | iex`.
|
||||
|
||||
## What changed since 0.1.1
|
||||
|
||||
**Components that measure, as in Chrome (#54, #13).** Many components written for the web measure before they draw: a title sized to its box, captions wrapped where a line really ends, a caret after the last typed letter. In a composition those reads now answer as Chrome does, from the same layout and font files that draw the frame: `getBoundingClientRect` (through transforms and perspective), `offsetWidth` and the rest, `getComputedStyle`, a ref's children and selectors, `document.createElement`, Range, `document.fonts`, `ResizeObserver`, a canvas's `measureText`, and svg text's lengths. Hold the frame with `delayRender` and `continueRender` until a measure lands. Reads answer in live play too (the app's stage, `raea play`, exported games). In a render the first read in a frame costs about 0.4 ms, and more in the same frame almost nothing. Measured against headless Chrome on snapcn's measuring components, 23 of 33 now land within a pixel (3 before). The manual's new guide, "Web components that measure", lists what answers and what doesn't yet.
|
||||
|
||||
**Text set as Chrome sets it.** Letters set a span each keep their kerning. A `visibility: hidden` word keeps its place and isn't drawn. A web font from `loadFont` is the one measured and drawn at every weight (raea's own Inter drew 500 as 400 and 600 as 700), and it's loaded before your first effect runs. A canvas's `system-ui` is the Mac's system font. An svg `<text>` with letter-spacing lands where Chrome puts it.
|
||||
|
||||
**Canvas, requestAnimationFrame and Image (#55, #56).** Compositions get the web's 2D canvas context, `requestAnimationFrame` (called once per frame drawn, with that frame's time) and `new Image()`.
|
||||
|
||||
**raea learns what you judge good.** `raea fingerprint` keeps a fingerprint of your taste: axes such as blur, glow or a frozen picture, each a small model over encoders that run on your Mac (SigLIP 2 for pictures, CLAP and YAMNet for sound, EmbeddingGemma for scripts). Your notes, approvals and picks between two cuts teach it, and `raea fingerprint score` says where a piece stands on each axis and whether a fix fixed what it claimed (`--was OLD`). `raea fingerprint things` finds a shot's things, their depth and the ground under them, and `raea check --things` reports one floating, passing through another, or a camera that changes speed mid-move. Archiving a project runs a post-mortem. The app has a Fingerprint page: what it knows, what it's learning, and fingerprints of your own for different kinds of work.
|
||||
|
||||
**One timeline in the player.** A video's player in the app is one deck: the picture on top, the sound under it and your comments' pins between them. The picture track shows frames, energy, scenes, captions or checks, and the sound track a waveform, beats or words; what a render hasn't got yet is offered with its verb (Transcribe, Detect). An agent at work has a stop button wherever the app shows it working, a feed or the Inbox can be summed up on its timeline, and a new project waits for you to make the first move.
|
||||
|
||||
**Review links by email.** Under a live review link in the Share panel, type up to 25 addresses and an optional note, and raea mails them the link. Sign-in codes come by email too.
|
||||
|
||||
**Video with alpha (#113).** A VP9 WebM's transparency and a ProRes 4444's are drawn, not refused or made opaque, and `render --alpha` leaves a frame with 3D transparent where nothing is drawn (#114).
|
||||
|
||||
**Projects with room to grow.** A new project has compositions/, components/, controllers/, assets/ and artifacts/, and a workspace has shared/ for what every project imports as `@shared/...`. `raea component add` (raea part's new name, which still works) copies a ready component into the project, or into shared/ with `--shared`.
|
||||
|
||||
**raea's Claude plugin** installs from raea's marketplace and is the raea skill with its two hooks, which run raea locally and send nothing.
|
||||
|
||||
**Fixes**
|
||||
- The Windows app stays open when a video opens: every raea executable on Windows now has an 8 MB main-thread stack, not the 1 MB default (#112).
|
||||
- The Windows app no longer crashes at launch reading a blob: FileReader, fetch's request body and a WebSocket's binary send turn bytes into a string a slice at a time, and a frame's own script is found under the app's folder (#124).
|
||||
- When an agent's Claude sign-in runs out mid-conversation, the app says so and signs you in again there, instead of failing every turn (#111).
|
||||
- On a Retina display the page fills the window instead of a quarter of it (#120, with Treamz), and the window is sharp.
|
||||
- A frame that comes out all black though its page shows something is a warning, said once over its run of frames (#96), and a filter of opacity() alone draws as the layer's opacity (#96).
|
||||
- Dark gradients no longer band in 8-bit H.264: the colour conversion dithers (#87).
|
||||
- canvas `arcTo` draws the corner's short arc, as a browser does (#97).
|
||||
- A Cone takes clicks only across its height (#98).
|
||||
- A mesh's emissive colour changes the frame it's set in live 3D (#106).
|
||||
- `getBoundingClientRect` no longer panics on a removed element and answers a zero rect under `display: none` (#108).
|
||||
- A relayout keeps an inline box's baseline (#109).
|
||||
- `raea check`'s safe-area rule tests a text's letters, not its box; a card that shares one word with a line isn't held to it as a caption; and a missing taste file is a note (#89, #102, with SirSicard).
|
||||
- `raea cut` takes a sound-only take (#89).
|
||||
- A still no longer prints dozens of CommandQueue warnings, and the 3D camera is the shadow origin (#89, #104, with SirSicard).
|
||||
- A fresh `raea init` renders again.
|
||||
- R3F: an opacity outside 0 to 1 is clamped instead of throwing (#117), and three.js 0.180 or later is the peer range (#118), both with Ragulsundaram. The three.js host draws `<Instances>` at each placement.
|
||||
- A ShaderMaterial under Solari lighting draws instead of failing its prepass.
|
||||
- raea's own commits work on a machine whose git has no `user.name`.
|
||||
- `import.meta.url` is set in every module on macOS 15.
|
||||
|
||||
Thank you to everyone who filed issues and sent PRs this round: augusbazan, SirSicard, Ragulsundaram, Treamz, revouwu, kevinschaich, connorads and Razepriv.
|
||||
|
||||
Its binaries are `v0.1.2-rc5`'s, built from 1be8199c8 and checked there.
|
||||
|
||||
## Known missing
|
||||
|
||||
- Of snapcn's measuring components, 10 still don't land within a pixel of Chrome (a font's tracking table, a few transforms' ink); docs/layout-reads.feature lists each. A Range across wrapped lines is one rect, and an element has no `innerHTML`.
|
||||
- `raea fingerprint` doesn't judge how real a sound is yet: it was measured on CC0 and CC BY recordings and didn't clear the bar for every kind of sound.
|
||||
- The Windows and Linux apps don't update themselves yet: download the next version from raea.io.
|
||||
- On Linux, raea needs ALSA, fontconfig and Vulkan (Ubuntu 24.04: `sudo apt install libasound2t64 libfontconfig1 libvulkan1 mesa-vulkan-drivers`).
|
||||
- The OCR half of the reading check runs on the Mac only.
|
||||
- The engine's own binaries aren't notarized. The Mac app is signed and notarized.
|
||||
@@ -0,0 +1,294 @@
|
||||
@spec
|
||||
Feature: Scene: a feed item that is raea 3D looked at from inside
|
||||
Shane, 2026-11-13: "create one new feed 'scene' which allow you to look inside a raea 3d scene and a 'storyboard' of
|
||||
them or a grid of props, characters or anything you might want to inspect, comment on or anything. this is critical
|
||||
that this is a highly intentional but minimalist way to inspect a scene with a timeline unless its just static or a
|
||||
prop and be able to actually move around in the scene, make comments in 3d space, and possibly move, rotate and
|
||||
scale objects in the scene unless they are procedural to which we might need an item details panel that has
|
||||
components that are procedural show up with those props. A big part of this is being able to highlight a problem
|
||||
with the mesh, maybe how the shader looks or a clipping or artifact problem. being able to even stage the scene by
|
||||
drawing components in 3d space or adjust motion trajectories like i would a spline." Later the same day: "timeline
|
||||
should be same sdk and components we use for watch", and it is for v0.1.4.
|
||||
|
||||
What there was (read 11-13): a 3D scene reached the feed only as a render (watch), a still (look) or a game (play).
|
||||
The preview pages (docs/preview.feature) had the pieces under them: the stage picks 3D parts and answers where
|
||||
points of the scene are on the picture, a free camera, a part's JSX read and set where it is written. None of it was
|
||||
a thing an agent could post for the person to walk around in, and nothing moved a part, drew one or touched motion.
|
||||
|
||||
The item:
|
||||
- `scene` is a feed item type. Its entries are files the stage can open: a 3D composition's .tsx, a component's
|
||||
.tsx (a prop, a character), a model, a splat. One entry opens straight into the inspector; several are a board
|
||||
first.
|
||||
- The file is the document. Every change made in the inspector is written into the scene's own code, in the form
|
||||
it is already written in, with Undo. Nothing is kept beside it.
|
||||
- Only what matters now is on the picture: the scene, the one toolbar, and the timeline when time is part of it.
|
||||
A picked part brings its card; a tool brings its own marks. Cruft is clutter (Shane, 11-13): everything a
|
||||
person can do is a tool in the side toolbar, where they look for it, and what a thing is is said in its tooltip,
|
||||
not in words on the picture.
|
||||
|
||||
Background:
|
||||
Given the app's code is apps/app (raea-feed): src/scene, src/detail/views/Scene.tsx, host/scene, samples/scene
|
||||
And the inspector is built on stage.show, stage.pick, stage.view, stage.locate, stage.seek and stage.play as
|
||||
docs/preview.feature PV1 left them, and on three calls added for it (raea-sys-hold, raea-runtime-live
|
||||
pick3d.rs, raea-page-stage): stage.part (where a part stands), stage.hold (a part drawn where a drag has it)
|
||||
and stage.wire (wireframe). On a raea without them it still works: handles from the code's numbers, no live
|
||||
drag, and Wireframe says it can't yet
|
||||
And everything the inspector knows of the camera is where points of the scene are on the picture (stage.locate):
|
||||
a plane of the scene is mapped to the picture by a homography from four of its points (src/scene/math.ts), so a
|
||||
drag is read in true metres from the scene's own camera as from a free one, whatever lens the scene wrote
|
||||
|
||||
Rule: SF1. The item, its board and how it is posted
|
||||
# Status 11-13: built on raea-feed branch scene. feed_post { type: "scene", file, files?, names? } (host/acp/hub.ts
|
||||
# scenePost: each file stays where it is and is checked to be one the stage opens); `raea show` posts models, or
|
||||
# several 3D files, as a scene (host/show.ts typeOf); the built-in world has one (i-set: samples/scene room.tsx,
|
||||
# crate.tsx, lamp.tsx). Checked in Chrome (e2e/scene.spec.ts) and in raea's headless window: the card's stills, the
|
||||
# board, an entry opened, Esc back to the board and then the feed.
|
||||
|
||||
@done
|
||||
Scenario: SF1a. One scene, or a board of them
|
||||
Given a scene item with one entry
|
||||
Then it opens in the inspector
|
||||
Given one with several (a storyboard's shots, a grid of props or characters)
|
||||
Then it opens on a board: each entry's still, its name, what the poster called it, and its open comments' count;
|
||||
shots are numbered in order
|
||||
And a click opens an entry, B or Esc goes back to the board, Esc again to the feed
|
||||
And the feed's card is the first four stills
|
||||
|
||||
@done
|
||||
Scenario: SF1b. Posting one
|
||||
Then an agent posts it with feed_post type scene (file, and files for a board, names for what each is called)
|
||||
And `raea show` of a model, or of several 3D files, shows them as a scene
|
||||
And an item written into a project's .raea/feed with type scene and entries is drawn the same
|
||||
|
||||
Rule: SF2. Looking around, with a timeline only when there is time
|
||||
# Status 11-13: built (src/scene/Inspector.tsx; the camera is an orbit about a target, math.ts turned, slid,
|
||||
# dollied, walked, framed, between). Checked in the headless window on the sample room: a drag turned the view, the
|
||||
# wheel moved out, F came back, a timed scene played and a press on the strip went to 0:01.5 with the ball mid-arc;
|
||||
# a prop alone had no strip.
|
||||
|
||||
@done
|
||||
Scenario: SF2a. Moving through the scene
|
||||
When the pointer is at rest (no other tool on)
|
||||
Then a drag turns the view about what it looks at, Shift-drag slides it, the wheel moves in and out, the arrow
|
||||
keys walk along the ground the way the camera faces, Page Up and Page Down rise and sink
|
||||
And Alt-drag or the right button does the same from any tool
|
||||
And F frames the picked part, or with none goes back to the scene's own camera; a double click does too
|
||||
And the scene opens on its own camera, as its author framed it
|
||||
|
||||
@done
|
||||
Scenario: SF2d. The tools' bar
|
||||
Then the side toolbar holds every tool: Look, Comment, Draw, Path, Check, Wireframe, Quality, and Board on an
|
||||
item with several entries; Move, Rotate and Scale stand in it only while a part a hand can change is picked
|
||||
And each says what it does and its key in its tooltip, as do the handles, the keys, the card's rows and buttons
|
||||
and the kinds of problem a comment can mark
|
||||
|
||||
@done
|
||||
Scenario: SF2e. The view has a toolbar of its own
|
||||
# Shane, 11-13: "lets have separated toolbars for movement controls and maybe some kind of hint if movement
|
||||
# controls have a shortcut by putting it in the tooltip". src/scene/NavBar.tsx, on the stage's right edge.
|
||||
Then across from the tools is the view's bar: Orbit (1), Pan (2) and Zoom (3) set what a plain drag does, Frame
|
||||
(F) goes onto the picked part or the whole scene, and the scene's camera (0) goes back to the shot as written
|
||||
And each tooltip says its key and the gesture that does the same from any mode (Shift-drag slides, scrolling
|
||||
moves in and out, the arrows walk)
|
||||
|
||||
@done
|
||||
Scenario: SF2b. The timeline is the watch view's own
|
||||
Given a scene whose composition has a length
|
||||
Then under the picture is the feed's one timeline (detail/blocks/Filmstrip.tsx, as under a render): play and the
|
||||
time on its row, the playhead, the comments' marks at their moments, a press or a drag to seek
|
||||
And its lanes are the scene's own frames, cuts and sound, from a render of the scene as it is now (host/scene
|
||||
film: kept by the file's state, made in the background a moment after it is live and after each change, not
|
||||
while this Mac is short of memory); the strip keeps one height before and after it arrives
|
||||
Given a still scene, a prop or a model
|
||||
Then there is no timeline
|
||||
|
||||
@done
|
||||
Scenario: SF2c. A prop or a model alone
|
||||
Then a component opens alone under plain light from the front three-quarter (its own camera and lights when it
|
||||
brings them), framed by what is drawn; a model as its preview page shows it
|
||||
|
||||
Rule: SF3. Comments in the scene's space
|
||||
# Status 11-13: built (src/scene/Pins.tsx; model/types.ts Pin.space; model/pin.ts spaceLines). A pin is a place
|
||||
# pin with `space`: the point in the scene's space, the part's stamp, a radius, what it marks, the view it was
|
||||
# written from, a path. Checked in the headless window: a comment on the table top marked Shader posted as an
|
||||
# edit, its pin stayed on the surface through a turn and a move out, and its mark stood at 0:00 on the timeline. A
|
||||
# drag marked a region as Artifact (its ring drawn on the table); opened from its mark after a seek to 0:01.5 it
|
||||
# went back to 0:00 with its thread open, and Esc closed the thread and stayed in the entry. A path of three
|
||||
# points posted as a comment.
|
||||
|
||||
@done
|
||||
Scenario: SF3a. A note on a point of a surface
|
||||
When Comment is on and I click a part
|
||||
Then the feed's own composer opens beside the point, and the comment is pinned to that point of that part
|
||||
And its pin is drawn where the point is from any camera and at any frame; away from its moment it is fainter
|
||||
And the agent reads where it is in the scene's space, on which part and where that part is written
|
||||
|
||||
@done
|
||||
Scenario: SF3b. What it marks
|
||||
Then the composer offers Mesh, Shader, Clipping and Artifact, and the comment carries the one chosen: the agent
|
||||
is told which kind of problem it is
|
||||
And a drag instead of a click marks a region: a ring about the point, its radius in metres
|
||||
|
||||
@done
|
||||
Scenario: SF3c. A comment opened
|
||||
When a comment is opened from its pin, the notes or the timeline
|
||||
Then the scene goes to its entry and its moment, and the view moves to the one it was written from (the scene's
|
||||
own camera when it was written from that)
|
||||
And Esc closes the comment first, then the entry
|
||||
|
||||
@done
|
||||
Scenario: SF3d. What raea itself measures
|
||||
When Check is pressed
|
||||
Then raea's scene lint (docs/scene.feature) runs on the frame shown and says what floats, sinks or clips
|
||||
|
||||
@done
|
||||
Scenario: SF3e. Seeing what a mesh is made of
|
||||
When Wireframe is on
|
||||
Then every mesh is drawn as its edges over its shading (Bevy's wireframe pass, on the stage's scenes only: a
|
||||
render's graph never has it), through play, a seek and a change to the code
|
||||
|
||||
Rule: SF4. Moving, turning and scaling a part by hand
|
||||
# Status 11-13: built (src/scene/Gizmo.tsx; host/scene/place.ts). Both forms raea scenes are written in are read
|
||||
# and written: Bevy's Transform chain (fromXyz, withRotation(Quat.fromEuler("XYZ", ...)), withScale; a lookingAt
|
||||
# kept last) and position/rotation/scale props; a part with none gets its tag's form and the imports it needs.
|
||||
# Checked in the headless window (blitz/scene.mjs): the crate's x handle dragged 66 px wrote fromXyz(2.3878, 0.35,
|
||||
# -1.2) with its rotation untouched, the stage drew it there, and Undo put the file back to the byte. By hand
|
||||
# after: the y ring turned it to Quat.fromEuler("XYZ", 0, 0.106, 0), the y handle scaled it to withScale([1,
|
||||
# 1.4656, 1]), and two Undos put the line back. The handles are elements over the picture and a drag is followed
|
||||
# on the window: raea's window draws an inline SVG as a picture, so its shapes take no pointer. host/scene: 15 tests.
|
||||
|
||||
@done
|
||||
Scenario: SF4a. Handles on a part placed by numbers
|
||||
When I click a part whose position is written as numbers
|
||||
Then Move (G), Turn (R) and Scale (S) are in the toolbar, and three axes stand from where it stands: a drag
|
||||
along one moves it along that axis, the middle slides it over the ground; Turn's rings turn it about an axis,
|
||||
Scale's handles size it; Shift snaps (10 cm, 15 degrees, a tenth)
|
||||
And while it is dragged its outline and the amount show; on release the new placement is written into its JSX
|
||||
in the form it is in, and the stage shows it
|
||||
And its card has the same numbers to type over, and Undo
|
||||
|
||||
@done
|
||||
Scenario: SF4c. The part follows the drag
|
||||
# checked in the built app's headless window: mid-drag the jar stood 43.2 cm along x with its card still
|
||||
# reading its old numbers, and the release wrote them
|
||||
Then while a handle is dragged the part itself is drawn where the drag has it (the stage holds it there;
|
||||
nothing is written), its outline and handles with it, and the amount beside it
|
||||
And the release writes it; a drag let go where it began writes nothing and the part goes back
|
||||
|
||||
@done
|
||||
Scenario: SF4d. A part inside a group that moves or turns it
|
||||
# the sample's jar on a trolley turned 0.7 rad: a 43.25 cm drag along the world's x wrote (-0.1308, 0.65,
|
||||
# -0.2786) from (0.2, 0.65, 0), that step turned back by the trolley's turn
|
||||
Then its handles stand on it where it is drawn (the stage says where a part stands)
|
||||
And a step in the world is written as the step in the space its code counts in: raea's groups are worked into
|
||||
each part's own place before the engine sees them, so that space is read from the part's turn and size in the
|
||||
world against those its code writes
|
||||
|
||||
@done
|
||||
Scenario: SF4b. A part placed by code has no handles
|
||||
Given a part whose position is computed (a frame's arithmetic, a spring, a prop, a loop's index)
|
||||
Then its card shows that code, Move is off and says why, and it is changed through its props (SF5)
|
||||
And a channel that is still numbers (a computed position with a plain scale) keeps its handle
|
||||
|
||||
Rule: SF5. The details of what is picked: a procedural part's props
|
||||
# Status 11-13: built (src/scene/Details.tsx; host/scene/routes.ts read, prop, default). A pick's stamp names the
|
||||
# components it was drawn in (its uses); each use's own element is read where it is written. Checked in the
|
||||
# headless window: a cone of the sample's row showed "Drawn by Cones" with count, gap and z; count typed to 6
|
||||
# wrote <Cones count={6}> and six cones stood; the crate prop alone showed size and color.
|
||||
|
||||
@done
|
||||
Scenario: SF5a. The card
|
||||
When a part is picked
|
||||
Then one card over the picture says its name, where it is written, where it stands, and its own props
|
||||
And nothing else is there until something is picked
|
||||
|
||||
@done
|
||||
Scenario: SF5b. Drawn by a component
|
||||
Given a part a component draws (a row, a scattering, a rig)
|
||||
Then the card lists each component it was drawn in, nearest first, with the props it was given where it is
|
||||
used, as controls; a change is written there and the stage shows it
|
||||
And a prop looked at alone lists its own props, a change writing its default
|
||||
|
||||
Rule: SF6. Staging: drawing parts into the scene
|
||||
# Status 11-13: built (host/scene/draw.ts; Inspector.tsx Draw). Checked in the headless window: a footprint
|
||||
# dragged on the floor wrote a <Mesh3d name="box"> with its Cuboid and material after the floor's element, the
|
||||
# imports added, standing on the floor; it was picked with its handles, and Remove took it out whole.
|
||||
|
||||
@done
|
||||
Scenario: SF6a. A primitive laid out on a surface
|
||||
When Draw is on and I drag on a surface
|
||||
Then a box, sphere, cylinder, cone or plane is laid out on the level through that point, its size shown as it
|
||||
is dragged
|
||||
And on release it is an element in the scene's file, among the scene's own top-level parts, written as raea 3D
|
||||
is written by hand; it is picked, to be moved, sized or removed
|
||||
|
||||
Rule: SF7. Motion as a path of keys
|
||||
# Status 11-13: built (src/scene/MotionPath.tsx; host/scene/motion.ts). A part's declared motion is its animate
|
||||
# tracks on x, y and z (raea/animation track, or plain keys). Checked in the headless window: the sample's ball
|
||||
# showed its path through keys 0, 45 and 90; the key at 45 dragged over the ground wrote 45: 0.8614 on x and
|
||||
# 45: 2.4329 on z and left y.
|
||||
|
||||
@done
|
||||
Scenario: SF7a. Keys moved as a spline's points
|
||||
Given a picked part whose animate declares x, y or z tracks with numbers
|
||||
Then its path is drawn through the scene as the tracks travel it, with a key at each keyed frame
|
||||
And a drag slides a key over the ground under it, with Shift straight up and down; the release writes that
|
||||
frame's values; a click on a key goes to its frame; the card adds a key at the frame shown
|
||||
|
||||
@done
|
||||
Scenario: SF7b. Motion that isn't keys is drawn on
|
||||
Given motion worked out in code
|
||||
Then Path draws a line through the scene (points on its surfaces), posted as a comment the agent reads as the
|
||||
points to move along
|
||||
|
||||
Rule: SF9. Light on the machine, and lighter when it must be
|
||||
# Status 11-13: built (src/scene/quality.ts, useLocated.ts stir; host/scene/routes.ts pressure). Shane, 11-13:
|
||||
# "make sure its highly performant and has ways to help kick back down preview rendering if swapping or
|
||||
# something". Measured in the headless window on the sample room (the window's whole process group): 3.2 GB at
|
||||
# the feed, 3.6 GB after blitz/scene.mjs (five reopenings), 3.7 GB after eight size changes and eight seconds of
|
||||
# play. At half size a part was picked and its handles stood on it. The rules for stepping down are tested
|
||||
# (quality.test.ts); a step down from real memory pressure was not seen live. Found and fixed on the way: a status
|
||||
# read while the stage was reopening a file said "playing", and the reopening after it played on by itself
|
||||
# (src/preview/stage.ts).
|
||||
|
||||
@done
|
||||
Scenario: SF9a. Quality
|
||||
Then Quality in the toolbar draws the scene at its own size, a half or a quarter: the same scene from the same
|
||||
camera, every pick, pin and handle working on it
|
||||
And on Auto it steps down by itself when this Mac is short of memory (the system's memory pressure, read by the
|
||||
host) or when the scene plays under half its frame rate for two seconds, and says why once, in a line over
|
||||
the toolbar and in the tool's tooltip
|
||||
|
||||
@done
|
||||
Scenario: SF9b. Nothing runs that nothing needs
|
||||
Then what is drawn over the picture follows it closely only while something changes (the camera, the clock, a
|
||||
drag, a write being drawn) and looks in now and then while it stands still
|
||||
And nothing is outlined under the pointer while the scene plays
|
||||
And while a scene is opening the host draws no stills beside it
|
||||
And a write keeps the picture, the handles and the pins where they are while the stage opens the file again,
|
||||
on the frame it stood on
|
||||
|
||||
Rule: SF10. What goes to the agent
|
||||
# Status 11-13: built (model/types.ts SceneItem.byHand; model/pin.ts byHandLines, spaceLines; store.tsx
|
||||
# sendComments). Shane, 11-13: "are we really going to count every single edit that was made? are we counting the
|
||||
# diffs?" No. model/pin.test.ts: 3 tests. The feed's send keycap (every item) reads "Send" with the count as a
|
||||
# badge: "Send 1 edit" ran together as "Send 1edit" in raea's window.
|
||||
|
||||
@done
|
||||
Scenario: SF10a. Comments are the edits; changes by hand are already made
|
||||
Then the count on Send is the comments marked as edits for the agent, as on every item
|
||||
And a part moved, turned, scaled, drawn or removed, a key dragged and a prop set are written when they are made:
|
||||
never counted, never waiting
|
||||
And the next round sent carries one line a thing changed by hand, for the agent to keep, and then forgets them
|
||||
And each comment in a scene tells the agent its point in the scene's space, the part and where it is written
|
||||
|
||||
Rule: SF8. Open
|
||||
# Status 11-13: SF8e done for 0.1.3 (Shane: the scene feed ships in 0.1.3, not 0.1.4). raea-feed #10 merged
|
||||
# (24b2eb5) with raea-skills #58 (faa9938: collaborate.md's row, reference/feed.md regenerated), and raea pins it
|
||||
# (#133, 2cb213634); SKILLS_STRICT=1 tools/skills.sh check passes against the app at raea-feed main.
|
||||
@done
|
||||
Scenario: SF8e. Taught to agents
|
||||
# feed_post's type list is in the generated skills reference. Teaching `scene` is a change to raea-skills
|
||||
# (skills/raea/collaborate.md's "When you need to..." table, and reference/feed.md regenerated), which is public
|
||||
# and merges by PR, with the merge of raea-feed's branch scene
|
||||
Then the raea skill says when to post a scene and what the person can do with it
|
||||
@@ -97,7 +97,10 @@ fn main() {
|
||||
);
|
||||
// on screen, bevy_winit's event loop is the runner (a ScheduleRunner here replaced it: no window, 11-04)
|
||||
if !a.window && !app.is_plugin_added::<ScheduleRunnerPlugin>() {
|
||||
app.add_plugins(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / 60.0)));
|
||||
// 60 frames a second, as most screens; RAEA_PAGE_FPS stands in for another screen's rate (a 120 Hz one, to
|
||||
// measure how a 60 fps video plays where the window draws twice a frame)
|
||||
let fps = std::env::var("RAEA_PAGE_FPS").ok().and_then(|v| v.parse::<f64>().ok()).filter(|f| (1.0..=480.0).contains(f)).unwrap_or(60.0);
|
||||
app.add_plugins(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / fps)));
|
||||
}
|
||||
app.add_plugins(HostPlugin { size: a.size, double_click: Duration::from_millis(500), picking })
|
||||
.add_plugins(brp::plugins(brp::port(), |r| r))
|
||||
|
||||
@@ -10,6 +10,21 @@ pub(super) fn settle(answer: raea_runtime_js::calls::Answer, r: Result<Value, St
|
||||
}
|
||||
}
|
||||
|
||||
/// A call for the stage's thread to answer; `idle` is the answer while the stage shows nothing.
|
||||
fn ask(w: &World, answer: raea_runtime_js::calls::Answer, idle: Value, cmd: impl FnOnce(raea_runtime_js::calls::Answer) -> Cmd) {
|
||||
let tx = w.resource::<Stage>().tx.lock().unwrap().clone();
|
||||
if let Some(tx) = tx {
|
||||
let _ = tx.send(cmd(answer));
|
||||
return;
|
||||
}
|
||||
answer.ok(idle)
|
||||
}
|
||||
|
||||
/// An argument that is exactly N numbers.
|
||||
fn numbers<const N: usize>(a: &Value, k: &str) -> Option<[f32; N]> {
|
||||
serde_json::from_value::<Vec<f32>>(a.get(k)?.clone()).ok()?.try_into().ok()
|
||||
}
|
||||
|
||||
/// The page's host calls (the module's list).
|
||||
pub(super) fn calls(mut calls: ResMut<HostCalls>) {
|
||||
let num = |a: &Value, k: &str| a.get(k).and_then(Value::as_f64);
|
||||
@@ -86,6 +101,20 @@ pub(super) fn calls(mut calls: ResMut<HostCalls>) {
|
||||
None => answer.err("the stage shows nothing"),
|
||||
}
|
||||
})
|
||||
.on("stage.part", move |w, a, answer| ask(w, answer, Value::Null, |to| Cmd::Part(a["key"].as_str().unwrap_or_default().to_string(), to)))
|
||||
.on("stage.hold", move |w, a, answer| {
|
||||
let place = match (a["release"] == true, numbers(&a, "translation"), numbers(&a, "rotation"), numbers(&a, "scale")) {
|
||||
(true, ..) => None,
|
||||
(_, Some(t), Some(r), Some(s)) => Some((t, r, s)),
|
||||
_ => return answer.err("stage.hold takes a key with translation [x, y, z], rotation [x, y, z, w] and scale [x, y, z], or release: true"),
|
||||
};
|
||||
let key = a.get("key").and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
ask(w, answer, json!(false), |to| Cmd::Hold(key, place, to))
|
||||
})
|
||||
.on("stage.wire", move |w, a, answer| {
|
||||
let on = a.get("on").and_then(Value::as_bool).unwrap_or(true);
|
||||
ask(w, answer, json!(false), |to| Cmd::Wire(on, to))
|
||||
})
|
||||
.on("stage.inspect", move |w, a, answer| {
|
||||
let id = a.get("id").and_then(Value::as_u64).unwrap_or(0);
|
||||
let tx = w.resource::<Stage>().tx.lock().unwrap().clone();
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
//! note's pin follow what they are on)
|
||||
//! stage.props {props} the composition's props set over its defaults as it plays (PV4b): the frame it is on is
|
||||
//! drawn again with them; nothing is reopened or written
|
||||
//! stage.part {key} the part that key names as it stands now ({entity_key, placed}), or null
|
||||
//! (docs/scene-feed.feature SF4c); a pick's part carries the same `placed`: {local,
|
||||
//! world: {translation, rotation [x, y, z, w], scale}, parent: 16 numbers | null}
|
||||
//! stage.hold {key, translation, rotation, scale} | {key, release: true}
|
||||
//! that part drawn at a place in its parent's space until it is let go of: a drag
|
||||
//! as it looks while it is dragged; nothing is written
|
||||
//! stage.wire {on} every mesh drawn as its edges over its shading (SF3e); answers whether it can
|
||||
//! stage.inspect {id} that element as it is now (its owner, kind, box, props, text), or null once it's gone
|
||||
//! stage.tweak {changes} [{owner, kind, prop, value}]: the props written into the composition as its next
|
||||
//! version (raea-sys-tweak), which the stage then shows at the same frame, its input replayed
|
||||
@@ -69,6 +76,12 @@ enum Cmd {
|
||||
Locate(Vec<String>, Vec<[f32; 3]>, Answer),
|
||||
/// props over the composition's defaults, from now
|
||||
Props(Value, Answer),
|
||||
/// a part by its key, as it stands now
|
||||
Part(String, Answer),
|
||||
/// a part held at a place in its parent's space (None: let go of)
|
||||
Hold(String, Option<([f32; 3], [f32; 4], [f32; 3])>, Answer),
|
||||
/// the scene as wireframe, or as it is
|
||||
Wire(bool, Answer),
|
||||
/// an element as it is now, by id
|
||||
Inspect(u64, Answer),
|
||||
/// props written into the next version, which then plays from the same frame
|
||||
@@ -144,6 +157,8 @@ impl Plugin for StagePlugin {
|
||||
// SAFETY: the app is being built on its main thread; the stage's thread starts at the first show
|
||||
unsafe { std::env::set_var("RAEA_SOURCE_STAMPS", "1") };
|
||||
}
|
||||
// the stage's scenes can be drawn as wireframe (docs/scene-feed.feature SF3e): asked for before any opens
|
||||
raea_runtime_live::want_wire();
|
||||
app.insert_resource(stage)
|
||||
.init_resource::<HostCalls>()
|
||||
.add_plugins(ExtractResourcePlugin::<Stage>::default())
|
||||
@@ -214,6 +229,8 @@ fn run(rx: Receiver<Cmd>, status: Arc<Mutex<Status>>, slot: Arc<Mutex<Painted>>)
|
||||
};
|
||||
// paused: the frames asked for and not yet stepped (at most 4 a turn, as playing)
|
||||
let mut steps = 0i64;
|
||||
// the scene shown as wireframe (stage.wire), and a file just opened that hasn't taken it yet
|
||||
let (mut wire, mut rewire) = (false, false);
|
||||
// RAEA_STAGE_TRACE=1: each frame stepped and its keys, on stderr
|
||||
let trace = std::env::var("RAEA_STAGE_TRACE").as_deref() == Ok("1");
|
||||
// the stage's size, which the page's points are in
|
||||
@@ -256,6 +273,7 @@ fn run(rx: Receiver<Cmd>, status: Arc<Mutex<Status>>, slot: Arc<Mutex<Painted>>)
|
||||
Ok(l) => {
|
||||
status.lock().unwrap().fps = l.fps;
|
||||
live = Some(l);
|
||||
rewire = wire;
|
||||
}
|
||||
Err(e) => set_error(e),
|
||||
}
|
||||
@@ -328,6 +346,18 @@ fn run(rx: Receiver<Cmd>, status: Arc<Mutex<Status>>, slot: Arc<Mutex<Painted>>)
|
||||
}
|
||||
None => answer.ok(Value::Null),
|
||||
},
|
||||
Some(Cmd::Part(key, answer)) => answer.ok(live.as_mut().and_then(|l| l.part(&key)).unwrap_or(Value::Null)),
|
||||
Some(Cmd::Hold(key, to, answer)) => {
|
||||
let held = live.as_mut().is_some_and(|l| l.hold(&key, to));
|
||||
repaint |= held;
|
||||
answer.ok(json!(held));
|
||||
}
|
||||
Some(Cmd::Wire(on, answer)) => {
|
||||
wire = on;
|
||||
let can = live.as_mut().is_some_and(|l| l.wire(on));
|
||||
repaint |= can;
|
||||
answer.ok(json!(can));
|
||||
}
|
||||
Some(Cmd::Inspect(id, answer)) => match live.as_mut() {
|
||||
Some(l) => answer.ok(l.element(id).map(|e| on_stage(e, l, stage)).unwrap_or(Value::Null)),
|
||||
None => answer.ok(Value::Null),
|
||||
@@ -352,6 +382,12 @@ fn run(rx: Receiver<Cmd>, status: Arc<Mutex<Status>>, slot: Arc<Mutex<Painted>>)
|
||||
None => {}
|
||||
}
|
||||
let Some(l) = live.as_mut() else { continue };
|
||||
// a file opened again while the scene was shown as wireframe: its 3D is made on a thread, so it is asked each
|
||||
// turn until it is there to take it
|
||||
if rewire && l.wire(true) {
|
||||
rewire = false;
|
||||
repaint = true;
|
||||
}
|
||||
let due = if playing { base + (since.elapsed().as_secs_f64() * l.fps) as i64 } else { frame + steps };
|
||||
let mut stepped = 0;
|
||||
while frame < due && stepped < 4 {
|
||||
|
||||
@@ -9,6 +9,8 @@ description = "raea's render engine: an edit's rows drawn by Bevy (3D) or the di
|
||||
[dependencies]
|
||||
# a frame's rows as the passes read them (FrameRows, the edit, the clock, row helpers, bevy_api)
|
||||
raea-sys-frame = { path = "../../systems/frame" }
|
||||
# a part held where a hand has it, and wireframe (the app's scene inspector)
|
||||
raea-sys-hold = { path = "../../systems/hold" }
|
||||
# the passes, each a crate of its own (systems/)
|
||||
raea-sys-splat = { path = "../../systems/splat" }
|
||||
raea-sys-sprite = { path = "../../systems/sprite" }
|
||||
|
||||
@@ -189,6 +189,7 @@ impl Engine {
|
||||
let backend = raea_io_media::backend(&media_backend())?;
|
||||
app.insert_non_send(Media { backend, decoders: HashMap::new(), dir: dir.to_path_buf() });
|
||||
}
|
||||
raea_sys_hold::install(&mut app, live); // a part held by a hand, and wireframe (docs/scene-feed.feature SF4c, SF3e)
|
||||
mem_mark("engine: plugins built (DefaultPlugins, the render device)");
|
||||
Ok(Opening { app, prog: prog.clone(), inserted: inserted.to_vec(), dir: dir.to_path_buf(), timeline, live })
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
//! VideoToolbox's BGRA as the RGBA a Frame holds.
|
||||
|
||||
/// A row of BGRA as RGBA, its alpha kept or made 255. Four bytes at a time as one word, which the compiler turns into
|
||||
/// vector code: a 4K frame took 5.5 ms a byte at a time, most of what playing one cost (RAEA_MEDIA_STATS, 11-13).
|
||||
pub(crate) fn bgra_to_rgba(src: &[u8], dst: &mut [u8], alpha: bool) {
|
||||
let opaque = if alpha { 0 } else { 0xff00_0000 };
|
||||
for (d, s) in dst.chunks_exact_mut(4).zip(src.chunks_exact(4)) {
|
||||
let v = u32::from_le_bytes([s[0], s[1], s[2], s[3]]);
|
||||
let out = (v & 0xff00_ff00) | ((v & 0xff) << 16) | ((v >> 16) & 0xff) | opaque;
|
||||
d.copy_from_slice(&out.to_le_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::bgra_to_rgba;
|
||||
|
||||
#[test]
|
||||
fn bgra_becomes_rgba_with_its_alpha_kept_or_made_opaque() {
|
||||
let src = [10, 20, 30, 40, 1, 2, 3, 0];
|
||||
let mut out = [0u8; 8];
|
||||
bgra_to_rgba(&src, &mut out, true);
|
||||
assert_eq!(out, [30, 20, 10, 40, 3, 2, 1, 0]);
|
||||
bgra_to_rgba(&src, &mut out, false);
|
||||
assert_eq!(out, [30, 20, 10, 255, 3, 2, 1, 255]);
|
||||
}
|
||||
|
||||
/// A 4K frame's worth, timed (cargo test -p raea-io-apple --release convert -- --nocapture).
|
||||
#[test]
|
||||
fn a_4k_frame_is_converted_in_a_frame_s_small_part() {
|
||||
let src: Vec<u8> = (0..3840 * 2160 * 4).map(|i| (i % 251) as u8).collect();
|
||||
let mut out = vec![0u8; src.len()];
|
||||
let t = std::time::Instant::now();
|
||||
for _ in 0..10 {
|
||||
bgra_to_rgba(&src, &mut out, false);
|
||||
}
|
||||
eprintln!("4K BGRA to RGBA: {:.2} ms a frame", t.elapsed().as_secs_f64() * 100.0);
|
||||
assert_eq!(&out[..4], &[src[2], src[1], src[0], 255]);
|
||||
}
|
||||
}
|
||||
@@ -213,13 +213,7 @@ impl Decoder {
|
||||
let mut rgba = vec![0u8; w * h * 4];
|
||||
for y in 0..h {
|
||||
let row = std::slice::from_raw_parts(base.add(y * bpr), w * 4);
|
||||
let dst = &mut rgba[y * w * 4..(y + 1) * w * 4];
|
||||
for x in 0..w {
|
||||
dst[x * 4] = row[x * 4 + 2];
|
||||
dst[x * 4 + 1] = row[x * 4 + 1];
|
||||
dst[x * 4 + 2] = row[x * 4];
|
||||
dst[x * 4 + 3] = if self.alpha { row[x * 4 + 3] } else { 255 };
|
||||
}
|
||||
crate::convert::bgra_to_rgba(row, &mut rgba[y * w * 4..(y + 1) * w * 4], self.alpha);
|
||||
}
|
||||
rgba
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#![cfg(target_vendor = "apple")]
|
||||
|
||||
mod audio;
|
||||
mod convert;
|
||||
mod decode;
|
||||
mod encode;
|
||||
mod vt;
|
||||
|
||||
@@ -89,7 +89,10 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
|
||||
// never a stale export)
|
||||
let text = String::from_utf8_lossy(&bundle);
|
||||
let made: std::collections::HashSet<PathBuf> = std::fs::read_to_string(root.join("outputs.list")).unwrap_or_default().lines().map(PathBuf::from).collect();
|
||||
files.retain(|p| !made.contains(&std::fs::canonicalize(p).unwrap_or_else(|_| p.clone())) || p.file_stem().is_some_and(|n| text.contains(&*n.to_string_lossy())));
|
||||
// (a file is one of them only if its name is one of theirs, or it is a link to one: only those are resolved)
|
||||
let names: std::collections::HashSet<&std::ffi::OsStr> = made.iter().filter_map(|m| m.file_name()).collect();
|
||||
let may_be_made = |p: &Path| p.file_name().is_some_and(|n| names.contains(n)) || p.symlink_metadata().is_ok_and(|m| m.file_type().is_symlink());
|
||||
files.retain(|p| !may_be_made(p) || !made.contains(&std::fs::canonicalize(p).unwrap_or_else(|_| p.clone())) || p.file_stem().is_some_and(|n| text.contains(&*n.to_string_lossy())));
|
||||
// absolute media paths the bundle names (an import from outside the edit's folder becomes its path)
|
||||
for q in text.split('"').skip(1).step_by(2) {
|
||||
if q.starts_with('/') && q.len() < 4096 && Path::new(q).extension().and_then(|x| x.to_str()).is_some_and(|x| MEDIA_EXTS.contains(&x.to_ascii_lowercase().as_str())) {
|
||||
@@ -99,6 +102,9 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
|
||||
files.push(std::env::current_exe().ok().and_then(|e| std::fs::canonicalize(e).ok())?);
|
||||
files.sort();
|
||||
files.dedup();
|
||||
// the optimized copies there are, listed once: asking each media file for its own read its first and last MiB and
|
||||
// listed this folder again (2,417 files in one real project, before a render's first frame). Only a video has any
|
||||
let copies: Vec<String> = std::fs::read_dir(raea_io_media::mezz::dir()).map(|d| d.flatten().map(|e| e.file_name().to_string_lossy().into_owned()).collect()).unwrap_or_default();
|
||||
for p in &files {
|
||||
eat(p.as_os_str().as_encoded_bytes());
|
||||
match std::fs::metadata(p) {
|
||||
@@ -110,12 +116,14 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
|
||||
}
|
||||
// which file its decoders read: a video's optimized copy, once complete, changes the pixels without touching
|
||||
// the source (raea_io_media::mezz)
|
||||
if MEDIA_EXTS.contains(&p.extension().and_then(|x| x.to_str()).unwrap_or("").to_ascii_lowercase().as_str()) {
|
||||
if raea_io_media::mezz::has(p) {
|
||||
let video = matches!(p.extension().and_then(|x| x.to_str()).unwrap_or("").to_ascii_lowercase().as_str(), "mp4" | "mov" | "m4v");
|
||||
if video && !copies.is_empty() && let Some(fp) = raea_io_media::mezz::fingerprint(p) {
|
||||
// its whole copy (FP.EXT) and its range copies ([email protected]): the frames inside them come from the copies
|
||||
let named = |mark: char| copies.iter().any(|n| n.strip_prefix(fp.as_str()).is_some_and(|rest| rest.starts_with(mark) && !rest.contains("partial")));
|
||||
if named('.') {
|
||||
eat(b"mezz");
|
||||
}
|
||||
// its range copies too: the frames inside them come from the copies
|
||||
for r in raea_io_media::mezz::ranges(p) {
|
||||
for r in named('@').then(|| raea_io_media::mezz::ranges(p)).unwrap_or_default() {
|
||||
eat(format!("mezz@{}-{}", r.first, r.last).as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ pub fn bundle_fresh(tsx: &Path, out_js: &Path, o: &CompOpts, portable: Option<&P
|
||||
let work = std::env::temp_dir().join(format!("raea-cli-b{}", std::process::id()));
|
||||
remove_work(&work);
|
||||
copy_dir(&dir, &work.join("src"), 0)?;
|
||||
drop_tsconfigs(&work.join("src"), 0);
|
||||
let motion_src = raea_io_home::home().join("sdk/raea/src").canonicalize().map_err(|e| format!("raea/motion/src: {e}"))?;
|
||||
copy_dir(&motion_src, &work.join("motion"), 0)?;
|
||||
let sdks = sdks();
|
||||
|
||||
@@ -16,6 +16,25 @@ pub fn copy_dir(from: &Path, to: &Path, depth: usize) -> R<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The copy of an edit's folder without its own tsconfig.json and jsconfig.json files: the work folder's is the one a
|
||||
/// bundle resolves by. A project's own (raea writes one into every new project, for its editor) is the nearest to its
|
||||
/// sources, so the bundler read it in place of the work folder's: its `paths` name no live runtime, a played
|
||||
/// composition's `react` was the engine's React, and `raea play`, the app's stage and every still drawn by playing
|
||||
/// threw "__at is not a function" before the first frame (0.1.2; a render, which needs no such path, went through).
|
||||
pub fn drop_tsconfigs(dir: &Path, depth: usize) {
|
||||
let Ok(entries) = std::fs::read_dir(dir) else { return };
|
||||
for e in entries.flatten() {
|
||||
let p = e.path();
|
||||
if p.is_dir() {
|
||||
if depth < 6 {
|
||||
drop_tsconfigs(&p, depth + 1);
|
||||
}
|
||||
} else if matches!(e.file_name().to_str(), Some("tsconfig.json" | "jsconfig.json")) {
|
||||
let _ = std::fs::remove_file(&p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const MEDIA_EXTS: [&str; 10] = ["mp4", "mov", "m4v", "mp3", "wav", "m4a", "png", "jpg", "webp", "gif"];
|
||||
|
||||
/// The edit's source with its imports pointed at the bundle's copy of the SDK (its package name, a subpath such as /3d,
|
||||
@@ -107,8 +126,19 @@ pub fn sources(root: &Path) -> R<Vec<PathBuf>> {
|
||||
let mut stack = vec![root.to_path_buf()];
|
||||
while let Some(d) = stack.pop() {
|
||||
for e in std::fs::read_dir(&d).map_err(|e| format!("{}: {e}", d.display()))?.flatten() {
|
||||
// what copy_dir leaves out is no source of the edit's (a project's .git and node_modules were walked whole:
|
||||
// 2 s before a render's first frame in a project of ten thousand files)
|
||||
let name = e.file_name();
|
||||
if name.to_string_lossy().starts_with('.') || name == "node_modules" || name == "target" {
|
||||
continue;
|
||||
}
|
||||
let p = e.path();
|
||||
if p.is_dir() {
|
||||
// the entry's own kind, without another stat; a link is followed
|
||||
let dir = match e.file_type() {
|
||||
Ok(t) if !t.is_symlink() => t.is_dir(),
|
||||
_ => p.is_dir(),
|
||||
};
|
||||
if dir {
|
||||
stack.push(p);
|
||||
} else if matches!(p.extension().and_then(|x| x.to_str()), Some("ts" | "tsx" | "js" | "jsx" | "mjs")) {
|
||||
out.push(p.strip_prefix(root).unwrap().to_path_buf());
|
||||
|
||||
@@ -71,3 +71,35 @@ fn outside_copies_what_the_edit_imports_beyond_its_folder() {
|
||||
assert!(e.contains("lib/c.ts") && e.contains("outside raea's home"), "{e}");
|
||||
std::fs::remove_dir_all(&t).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_project_s_own_tsconfig_is_not_in_the_work_copy() {
|
||||
// raea writes a tsconfig.json into every new project: copied with the sources, it shadowed the work folder's
|
||||
let d = std::env::temp_dir().join(format!("raea-bundle-tsconfig-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(d.join("from/components")).unwrap();
|
||||
for f in ["from/tsconfig.json", "from/components/jsconfig.json", "from/a.tsx", "from/components/data.json"] {
|
||||
std::fs::write(d.join(f), "{}").unwrap();
|
||||
}
|
||||
copy_dir(&d.join("from"), &d.join("to"), 0).unwrap();
|
||||
drop_tsconfigs(&d.join("to"), 0);
|
||||
assert!(!d.join("to/tsconfig.json").exists() && !d.join("to/components/jsconfig.json").exists());
|
||||
assert!(d.join("to/a.tsx").exists() && d.join("to/components/data.json").exists());
|
||||
// the project's own files are untouched
|
||||
assert!(d.join("from/tsconfig.json").exists());
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_edit_s_sources_leave_out_hidden_folders_and_packages() {
|
||||
let d = std::env::temp_dir().join(format!("raea-bundle-sources-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
for f in ["a.tsx", "parts/b.ts", ".git/hooks/c.js", "node_modules/pkg/d.js", "target/e.ts", "out/f.json"] {
|
||||
std::fs::create_dir_all(d.join(f).parent().unwrap()).unwrap();
|
||||
std::fs::write(d.join(f), "").unwrap();
|
||||
}
|
||||
let mut got = sources(&d).unwrap();
|
||||
got.sort();
|
||||
assert_eq!(got, vec![PathBuf::from("a.tsx"), PathBuf::from("parts/b.ts")]);
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
+143
-10
@@ -5,15 +5,18 @@
|
||||
//! A seek is the prop `__seek` ([time, n], set by the dom layer's `currentTime`); playing is `__play` ([on, time, n,
|
||||
//! loop], set by `play()` and `pause()`), `__muted` the element's muted and `__volume` its volume. Playing, the decoder's frames come on the
|
||||
//! source's clock (its sound's: raea-runtime-js media_play.rs), each a `time` news for the element's currentTime, with
|
||||
//! `timeupdate` four times a second as a browser's, `playing` once it's going, and `ended` at its end. raea-runtime-dom's
|
||||
//! `timeupdate` four times a second as a browser's, `playing` once it's going, and `ended` at its end. A playing
|
||||
//! video's frames come ahead of their time, each with the moment it is due: at each sync (the page's own frame) the
|
||||
//! one due then is shown, so the picture keeps the page's rhythm whatever the decoder's. raea-runtime-dom's
|
||||
//! page host keeps one `Medias` and syncs it after each commit.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use blitz_dom::BaseDocument;
|
||||
use blitz_dom::node::{ImageData, RasterImageData, SpecialElementData};
|
||||
use raea_runtime_js::media_html::stream::{Cmd, Msg, Stream};
|
||||
use raea_runtime_js::media_html::stream::{Cmd, Halvings, Msg, Stream};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use raea_sys_page::ops::Nodes;
|
||||
@@ -35,6 +38,14 @@ pub struct Media {
|
||||
duration: f64,
|
||||
/// the latest frame: width, height, pixels
|
||||
frame: Option<(u32, u32, Arc<Vec<u8>>)>,
|
||||
/// what it is drawn from when it came as its size alone (its halving), until that goes to the painter with it
|
||||
halves: Halvings,
|
||||
/// how many halvings its decoder is asked to send with each frame
|
||||
halvings: u8,
|
||||
/// a playing video's frames not due yet: each its time, its picture and when to show it
|
||||
ahead: VecDeque<(f64, (u32, u32, Vec<u8>), Instant, Halvings)>,
|
||||
/// when this was last synced, and how far apart syncs have been lately (the page's frame, s)
|
||||
synced: (Option<Instant>, f64),
|
||||
/// `__play` as last seen, and whether it asks to play
|
||||
play: Option<Value>,
|
||||
playing: bool,
|
||||
@@ -42,6 +53,13 @@ pub struct Media {
|
||||
volume: Option<f64>,
|
||||
/// when the last `timeupdate` went
|
||||
told: Option<std::time::Instant>,
|
||||
/// RAEA_MEDIA_STATS=1: since when, frames shown, frames a newer one took the place of before the page drew, and
|
||||
/// the time setting the picture took (sum and max, ms)
|
||||
stats: Option<(std::time::Instant, u32, u32, f64, f64)>,
|
||||
/// RAEA_MEDIA_STATS=1: when a frame was last shown, and the longest wait between two this second (ms)
|
||||
shown_gap: (Option<std::time::Instant>, f64),
|
||||
/// RAEA_MEDIA_STATS=1, this second: the page's frames, the longest (ms), and how late frames were shown (sum, max; ms)
|
||||
paced: (u32, f64, f64, f64),
|
||||
}
|
||||
|
||||
impl Media {
|
||||
@@ -71,11 +89,12 @@ pub fn sync(doc: &mut BaseDocument, nodes: &Nodes, medias: &mut Medias, out: &mu
|
||||
Some(m) if m.src == src && m.load == load => m,
|
||||
_ => {
|
||||
let stream = (!src.is_empty()).then(|| raea_runtime_js::media_html::stream::open(&raea_sys_page::net::page_path(&src), video)).flatten();
|
||||
medias.insert(id, Media { src, load, poster: None, seek: None, stream, video, loaded: false, seeking: None, seeked: false, duration: f64::NAN, frame: None, play: None, playing: false, muted: None, volume: None, told: None });
|
||||
medias.insert(id, Media { src, load, poster: None, seek: None, stream, video, loaded: false, seeking: None, seeked: false, duration: f64::NAN, frame: None, halves: Vec::new(), halvings: 0, ahead: VecDeque::new(), synced: (None, 1.0 / 60.0), paced: (0, 0.0, 0.0, 0.0), play: None, playing: false, muted: None, volume: None, told: None, shown_gap: (None, 0.0), stats: (std::env::var("RAEA_MEDIA_STATS").as_deref() == Ok("1")).then(|| (std::time::Instant::now(), 0, 0, 0.0, 0.0)) });
|
||||
medias.get_mut(&id).unwrap()
|
||||
}
|
||||
};
|
||||
let mut redraw = false;
|
||||
let mut came = 0u32;
|
||||
if m.poster != poster {
|
||||
m.poster = poster;
|
||||
redraw = true;
|
||||
@@ -111,6 +130,7 @@ pub fn sync(doc: &mut BaseDocument, nodes: &Nodes, medias: &mut Medias, out: &mu
|
||||
st.ask(Cmd::Play { at: p.get(1).and_then(Value::as_f64).unwrap_or(0.0), looping: p.get(3).and_then(Value::as_bool).unwrap_or(false) });
|
||||
} else {
|
||||
st.ask(Cmd::Pause);
|
||||
m.ahead.clear();
|
||||
}
|
||||
}
|
||||
m.play = play;
|
||||
@@ -125,10 +145,14 @@ pub fn sync(doc: &mut BaseDocument, nodes: &Nodes, medias: &mut Medias, out: &mu
|
||||
bevy::log::warn!("raea-page: media: {err}");
|
||||
out.push(json!({"id": id, "type": "error", "message": err}));
|
||||
}
|
||||
Msg::Frame(t, f) => {
|
||||
Msg::Frame(t, f, halves) => {
|
||||
// the first frame or a seek's: shown now, and what was on its way for before the seek is not
|
||||
m.ahead.clear();
|
||||
let (w, h) = (f.width, f.height);
|
||||
m.frame = Some((w, h, Arc::new(f.rgba)));
|
||||
m.halves = halves;
|
||||
redraw = true;
|
||||
came += 1;
|
||||
if !m.loaded {
|
||||
m.loaded = true;
|
||||
out.push(json!({"id": id, "type": "loadeddata", "w": w, "h": h, "duration": m.duration}));
|
||||
@@ -142,6 +166,12 @@ pub fn sync(doc: &mut BaseDocument, nodes: &Nodes, medias: &mut Medias, out: &mu
|
||||
told(m, id, t, out);
|
||||
}
|
||||
}
|
||||
// a playing video's frame, for later; one that comes after a pause is for nothing
|
||||
Msg::Due(t, f, due, halves) => {
|
||||
if m.playing {
|
||||
m.ahead.push_back((t, (f.width, f.height, f.rgba), due, halves));
|
||||
}
|
||||
}
|
||||
Msg::Time(t) => {
|
||||
if m.landed(t) {
|
||||
out.push(json!({"id": id, "type": "seeked", "time": t}));
|
||||
@@ -152,13 +182,58 @@ pub fn sync(doc: &mut BaseDocument, nodes: &Nodes, medias: &mut Medias, out: &mu
|
||||
out.push(json!({"id": id, "type": "time", "time": t}));
|
||||
}
|
||||
}
|
||||
Msg::Playing(t) => out.push(json!({"id": id, "type": "playing", "time": t})),
|
||||
Msg::Playing(t) => {
|
||||
m.ahead.clear();
|
||||
out.push(json!({"id": id, "type": "playing", "time": t}));
|
||||
}
|
||||
Msg::Ended(t) => {
|
||||
m.playing = false;
|
||||
out.push(json!({"id": id, "type": "ended", "time": t}));
|
||||
}
|
||||
}
|
||||
}
|
||||
// the frame due at this sync: the latest whose moment has come, or comes within half a page frame (shown a
|
||||
// touch early rather than a whole page frame late); the ones before it were never seen
|
||||
let now = Instant::now();
|
||||
if let Some(last) = m.synced.0 {
|
||||
let dt = now.duration_since(last).as_secs_f64();
|
||||
m.synced.1 += 0.1 * (dt.min(0.1) - m.synced.1);
|
||||
if m.stats.is_some() && !m.ahead.is_empty() {
|
||||
(m.paced.0, m.paced.1) = (m.paced.0 + 1, m.paced.1.max(dt * 1e3));
|
||||
}
|
||||
}
|
||||
m.synced.0 = Some(now);
|
||||
let reach = now + Duration::from_secs_f64((0.5 * m.synced.1).min(0.008));
|
||||
let (due, passed) = due_by(&mut m.ahead, reach);
|
||||
came += passed;
|
||||
if let Some((t, (w, h, rgba), at, halves)) = due {
|
||||
m.halves = halves;
|
||||
let late = now.saturating_duration_since(at).as_secs_f64() * 1e3;
|
||||
(m.paced.2, m.paced.3) = (m.paced.2 + late, m.paced.3.max(late));
|
||||
m.frame = Some((w, h, Arc::new(rgba)));
|
||||
(redraw, m.seeked) = (true, true);
|
||||
came += 1;
|
||||
told(m, id, t, out);
|
||||
}
|
||||
// how many halvings its frames should come with: as many as bring one within twice the size it is drawn at
|
||||
// (the painter's rule, blitz-paint mip_level), counted from its box as last laid out
|
||||
if m.video && draw && let (Some((w, h, _)), Some(n), Some(st)) = (m.frame.as_ref(), nodes.by_id.get(&id), m.stream.as_mut()) {
|
||||
let want = doc.get_node(*n).map_or(0, |node| {
|
||||
let (l, scale) = (node.final_layout(), doc.viewport().scale_f64());
|
||||
let drawn = (l.content_box_width() as f64 * scale / *w as f64).min(l.content_box_height() as f64 * scale / *h as f64);
|
||||
let mut n = 0u8;
|
||||
while drawn > 0.0 && drawn * f64::from(1u32 << (n + 1)) <= 1.0 && n < 6 {
|
||||
n += 1;
|
||||
}
|
||||
n
|
||||
});
|
||||
// RAEA_MEDIA_HALVINGS=0: frames drawn as they come, as before (to compare with)
|
||||
let want = if std::env::var("RAEA_MEDIA_HALVINGS").as_deref() == Ok("0") { 0 } else { want };
|
||||
if want != m.halvings {
|
||||
m.halvings = want;
|
||||
st.ask(Cmd::Halvings(want));
|
||||
}
|
||||
}
|
||||
if redraw && m.video && draw {
|
||||
let pic = match (&m.poster, m.seeked) {
|
||||
(Some(p), false) => poster_image(p).map(|(w, h, px)| (w, h, Arc::new(px))),
|
||||
@@ -167,12 +242,38 @@ pub fn sync(doc: &mut BaseDocument, nodes: &Nodes, medias: &mut Medias, out: &mu
|
||||
// the frame's pixels shared, not copied again (a 4K frame is 33 MB)
|
||||
.or_else(|| m.frame.as_ref().map(|(w, h, px)| (*w, *h, px.clone())));
|
||||
if let (Some((w, h, px)), Some(n)) = (pic, nodes.by_id.get(&id)) {
|
||||
set_image(doc, *n, w, h, px);
|
||||
let began = std::time::Instant::now();
|
||||
set_image(doc, *n, w, h, px, std::mem::take(&mut m.halves));
|
||||
if let Some(s) = m.stats.as_mut().filter(|_| came > 0) {
|
||||
let ms = began.elapsed().as_secs_f64() * 1e3;
|
||||
(s.1, s.2, s.3, s.4) = (s.1 + 1, s.2 + came - 1, s.3 + ms, s.4.max(ms));
|
||||
if let Some(l) = m.shown_gap.0 {
|
||||
m.shown_gap.1 = m.shown_gap.1.max(began.duration_since(l).as_secs_f64() * 1e3);
|
||||
}
|
||||
m.shown_gap.0 = Some(began);
|
||||
let took = s.0.elapsed().as_secs_f64();
|
||||
if took >= 1.0 {
|
||||
eprintln!("raea-page: video {took:.2} s: {} frames shown ({w}x{h}), {} passed over before the page drew, picture set avg {:.2} ms max {:.2} ms, longest gap {:.0} ms; the page synced {} times, longest apart {:.0} ms; shown late avg {:.1} ms max {:.1} ms", s.1, s.2, s.3 / s.1.max(1) as f64, s.4, m.shown_gap.1, m.paced.0, m.paced.1, m.paced.2 / s.1.max(1) as f64, m.paced.3);
|
||||
*s = (std::time::Instant::now(), 0, 0, 0.0, 0.0);
|
||||
m.shown_gap.1 = 0.0;
|
||||
m.paced = (0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Of the frames waiting, the one to show by `reach`: the latest whose moment has come, taken out with the ones before
|
||||
/// it, and how many those were (frames nobody saw: the page drew less often than they came).
|
||||
fn due_by<T>(ahead: &mut VecDeque<(f64, T, Instant, Halvings)>, reach: Instant) -> (Option<(f64, T, Instant, Halvings)>, u32) {
|
||||
let (mut due, mut passed) = (None, 0);
|
||||
while ahead.front().is_some_and(|f| f.2 <= reach) {
|
||||
passed += due.replace(ahead.pop_front().unwrap()).is_some() as u32;
|
||||
}
|
||||
(due, passed)
|
||||
}
|
||||
|
||||
/// A playing element's time: each as `time` (its currentTime), and a `timeupdate` four times a second.
|
||||
fn told(m: &mut Media, id: u64, t: f64, out: &mut Vec<Value>) {
|
||||
out.push(json!({"id": id, "type": "time", "time": t}));
|
||||
@@ -197,12 +298,44 @@ fn poster_image(src: &str) -> Option<(u32, u32, Vec<u8>)> {
|
||||
Some((size.x, size.y, img.data?))
|
||||
}
|
||||
|
||||
/// Node `n` drawn as an image: `rgba` as its raster, its layout made again for the picture's size.
|
||||
fn set_image(doc: &mut BaseDocument, n: blitz_dom::NodeId, w: u32, h: u32, rgba: Arc<Vec<u8>>) {
|
||||
/// Node `n` drawn as an image: `rgba` as its raster. Its layout is made again only when the picture's size isn't the
|
||||
/// last one's: a playing video's next frame is the same size, and making its box and its ancestors' layout again for
|
||||
/// each was a part of every page frame it played in.
|
||||
fn set_image(doc: &mut BaseDocument, n: blitz_dom::NodeId, w: u32, h: u32, rgba: Arc<Vec<u8>>, halves: Halvings) {
|
||||
let Some(node) = doc.get_node_mut(n) else { return };
|
||||
let Some(el) = node.element_data_mut() else { return };
|
||||
el.special_data = SpecialElementData::Image(Box::new(ImageData::Raster(RasterImageData { width: w, height: h, data: vello::peniko::Blob::new(rgba) })));
|
||||
let same = matches!(&el.special_data, SpecialElementData::Image(i) if matches!(&**i, ImageData::Raster(r) if (r.width, r.height) == (w, h)));
|
||||
let image = RasterImageData { width: w, height: h, data: vello::peniko::Blob::new(rgba) };
|
||||
if !halves.is_empty() {
|
||||
raea_sys_page::preload_mips(&image, halves);
|
||||
}
|
||||
el.special_data = SpecialElementData::Image(Box::new(ImageData::Raster(image)));
|
||||
if same {
|
||||
return node.insert_damage(raea_sys_page::REPAINT_DAMAGE);
|
||||
}
|
||||
node.clear_layout_cache();
|
||||
node.insert_damage(raea_sys_page::ALL_DAMAGE);
|
||||
node.mark_ancestors_dirty();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// At a sync the frame shown is the latest one due by then; earlier ones due are passed over, later ones wait.
|
||||
#[test]
|
||||
fn the_frame_due_is_the_latest_whose_moment_has_come() {
|
||||
let t0 = Instant::now();
|
||||
let at = |ms: u64| t0 + Duration::from_millis(ms);
|
||||
let mut ahead: VecDeque<(f64, u8, Instant, Halvings)> = (0..4).map(|i| (i as f64 / 60.0, i as u8, at(17 * i as u64), Vec::new())).collect();
|
||||
// nothing is due before the first
|
||||
assert!(due_by(&mut ahead, t0 - Duration::from_millis(1)).0.is_none());
|
||||
// a page drawing as often as the frames come shows each
|
||||
assert_eq!(due_by(&mut ahead, at(0)).0.map(|f| f.1), Some(0));
|
||||
assert_eq!(due_by(&mut ahead, at(17)).0.map(|f| f.1), Some(1));
|
||||
// a page a frame late shows the latest and counts the one it passed
|
||||
let (due, passed) = due_by(&mut ahead, at(51));
|
||||
assert_eq!((due.map(|f| f.1), passed), (Some(3), 1));
|
||||
assert!(ahead.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ pub fn render(args: &[String]) -> R<String> {
|
||||
unsafe { std::env::set_var("RAEA_SOURCE_STAMPS", "1") };
|
||||
}
|
||||
bundle_composition(&tsx, &js, &o, None)?;
|
||||
raea_runtime_react::startup_mark("the composition bundled");
|
||||
let wanted = match (flag(args, "--frame"), flag(args, "--at")) {
|
||||
(Some(f), _) => Some(vec![f.parse().map_err(|_| "--frame takes a frame number")?]),
|
||||
(_, Some(at)) => Some(at.split(',').map(|f| f.trim().parse::<i64>().map_err(|_| "--at takes frame numbers".to_string())).collect::<R<_>>()?),
|
||||
@@ -91,6 +92,7 @@ pub fn render(args: &[String]) -> R<String> {
|
||||
};
|
||||
// a whole video made from these same inputs before is the export: cloned from the cache, not rendered again
|
||||
let cache = if wanted.is_none() && !raea_sys_layers::on() { export_cache(&tsx, &js, &out, args) } else { None };
|
||||
raea_runtime_react::startup_mark("the export cache looked up");
|
||||
let manifest = MANIFEST.lock().unwrap().clone();
|
||||
if let Some(c) = &cache {
|
||||
// with --manifest, the manifest kept beside the export comes back too
|
||||
|
||||
@@ -12,7 +12,11 @@ pub mod stream {
|
||||
/// where a playing source has got to, that it played to its end, or its failure.
|
||||
pub enum Msg {
|
||||
Meta { w: u32, h: u32, duration: f64 },
|
||||
Frame(f64, raea_io_media::Frame),
|
||||
/// a frame to show now (the first, a seek's). Asked for halvings (`Cmd::Halvings`), it comes as its size and
|
||||
/// the halving it is drawn from, its own pixels left behind
|
||||
Frame(f64, raea_io_media::Frame, Halvings),
|
||||
/// a playing video's frame, decoded ahead of its time: the frame at this time, to show at this moment
|
||||
Due(f64, raea_io_media::Frame, std::time::Instant, Halvings),
|
||||
/// a playing source's time (an audio one's, which has no frames; a video's when paused)
|
||||
Time(f64),
|
||||
/// playing from this time: the sound is on its way
|
||||
@@ -22,6 +26,48 @@ pub mod stream {
|
||||
Fail(String),
|
||||
}
|
||||
|
||||
/// Halvings of a frame, largest first: each a 2x2 mean of the one before (width, height, RGBA). A frame drawn at
|
||||
/// under half its size is drawn from one, so a 4K frame in a small player is neither sampled across four of
|
||||
/// its pixels at a time (it shimmers) nor sent whole to the GPU for every frame; and since the one it is drawn
|
||||
/// from is all that is sent, a quarter second of 4K frames waiting is 30 to 120 MB where whole it would be 500.
|
||||
pub type Halvings = Vec<(u32, u32, Vec<u8>)>;
|
||||
|
||||
/// `n` halvings of an RGBA picture (fewer once a side is a pixel).
|
||||
pub fn halvings(w: u32, h: u32, rgba: &[u8], n: u8) -> Halvings {
|
||||
let mut out: Halvings = Vec::new();
|
||||
for _ in 0..n {
|
||||
let (sw, sh, src) = match out.last() {
|
||||
Some(last) => (last.0, last.1, last.2.as_slice()),
|
||||
None => (w, h, rgba),
|
||||
};
|
||||
if sw < 2 || sh < 2 {
|
||||
break;
|
||||
}
|
||||
let (dw, dh) = ((sw / 2) as usize, (sh / 2) as usize);
|
||||
let stride = sw as usize * 4;
|
||||
let mut px = vec![0u8; dw * dh * 4];
|
||||
for (y, row) in px.chunks_exact_mut(dw * 4).enumerate() {
|
||||
let (top, bottom) = (&src[2 * y * stride..][..dw * 8], &src[(2 * y + 1) * stride..][..dw * 8]);
|
||||
for ((d, a), b) in row.chunks_exact_mut(4).zip(top.chunks_exact(8)).zip(bottom.chunks_exact(8)) {
|
||||
for c in 0..4 {
|
||||
d[c] = ((a[c] as u16 + a[c + 4] as u16 + b[c] as u16 + b[c + 4] as u16 + 2) / 4) as u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push((dw as u32, dh as u32, px));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A frame as it is sent when `n` halvings are asked for: whole with none; else its size, and the nth halving
|
||||
/// alone (the one it is drawn from).
|
||||
pub fn sent(f: raea_io_media::Frame, n: u8) -> (raea_io_media::Frame, Halvings) {
|
||||
match halvings(f.width, f.height, &f.rgba, n).pop() {
|
||||
Some(last) => (raea_io_media::Frame { rgba: Vec::new(), ..f }, vec![last]),
|
||||
None => (f, Vec::new()),
|
||||
}
|
||||
}
|
||||
|
||||
/// What the element asks of its decoder. Play plays from `at` on the source's clock (its sound's, when it has
|
||||
/// sound and a device): frames as they fall due, each `Frame` news, and `Ended` at its end unless `looping`.
|
||||
pub enum Cmd {
|
||||
@@ -31,6 +77,9 @@ pub mod stream {
|
||||
Muted(bool),
|
||||
/// the element's volume, 0..1: the sound's gain while it isn't muted
|
||||
Volume(f32),
|
||||
/// how many times each frame should be halved from here on (the page counts them from the size the video is
|
||||
/// drawn at; 0 while it is drawn at over half its size)
|
||||
Halvings(u8),
|
||||
}
|
||||
|
||||
pub struct Stream {
|
||||
@@ -133,7 +182,7 @@ pub mod stream {
|
||||
let i = dec.info().clone();
|
||||
let _ = tx.send(Msg::Meta { w: i.width, h: i.height, duration: i.duration });
|
||||
let _ = tx.send(match dec.frame_at(0.0) {
|
||||
Ok(f) => Msg::Frame(0.0, f),
|
||||
Ok(f) => Msg::Frame(0.0, f, Vec::new()),
|
||||
Err(e) => Msg::Fail(e),
|
||||
});
|
||||
Some(crate::media_play::Source::Video(dec))
|
||||
|
||||
+204
-31
@@ -1,13 +1,15 @@
|
||||
//! A `video` or `audio` playing (media_html.rs's stream, on its decoder's thread): seeks answered with the frame at the
|
||||
//! time asked; played, frames as they fall due on the source's clock, which is its sound's (media_sound.rs) when it has
|
||||
//! sound and the Mac a device, else the wall's. Frames are asked for at the clock's time, so a decoder that falls
|
||||
//! behind skips frames rather than letting the picture lag its sound.
|
||||
//! sound and the Mac a device, else the wall's. A playing video's frames are decoded a little ahead of the clock and
|
||||
//! sent with the moment each is due (`Msg::Due`), so how long a frame takes to decode is no part of when it is
|
||||
//! shown, and a loop's first frame is ready before its last has gone. A decoder that falls behind the clock skips
|
||||
//! frames rather than letting the picture lag its sound.
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::mpsc::{Receiver, RecvTimeoutError, Sender};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use crate::media_html::stream::{Cmd, Msg};
|
||||
use crate::media_html::stream::{Cmd, Msg, sent};
|
||||
use crate::media_sound::Sound;
|
||||
|
||||
/// What was opened: a video's decoder, or an audio source's samples.
|
||||
@@ -33,10 +35,54 @@ pub struct Player<'a> {
|
||||
volume: f32,
|
||||
clock: Option<Clock>,
|
||||
looping: bool,
|
||||
/// the frame (index at fps) last sent while playing, so a frame isn't decoded twice
|
||||
shown: Option<i64>,
|
||||
/// the frame (index at fps) to decode next while playing
|
||||
cursor: i64,
|
||||
/// what the cursor's frames are ahead of the clock by, in laps: `duration` once the cursor has gone round a
|
||||
/// loop the clock hasn't yet, else 0
|
||||
lap: f64,
|
||||
/// frames the clock passed before they were decoded, since the last frame sent (for the stats)
|
||||
skipped: i64,
|
||||
/// when the last Time news went (an audio source's, which has no frames)
|
||||
told: Option<Instant>,
|
||||
/// how many halvings each frame is sent with (`Cmd::Halvings`)
|
||||
halvings: u8,
|
||||
/// where the picture last sent was in time, while paused: sent again when the halvings asked for change
|
||||
still: Option<f64>,
|
||||
/// RAEA_MEDIA_STATS=1: how play is going, said a line a second
|
||||
stats: Option<Stats>,
|
||||
}
|
||||
|
||||
/// A second of play as the decoder's thread saw it (RAEA_MEDIA_STATS=1): the frames it sent, the frames the clock
|
||||
/// passed over (decoding fell behind, or the thread woke late), and how long a frame took to decode.
|
||||
struct Stats {
|
||||
since: Instant,
|
||||
frames: u32,
|
||||
skipped: u32,
|
||||
sum: f64,
|
||||
max: f64,
|
||||
/// the longest wait between two frames decoded, ms
|
||||
gap: f64,
|
||||
last: Option<Instant>,
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
fn new() -> Self {
|
||||
Stats { since: Instant::now(), frames: 0, skipped: 0, sum: 0.0, max: 0.0, gap: 0.0, last: None }
|
||||
}
|
||||
fn frame(&mut self, decode: Duration, skipped: i64, fps: f64) {
|
||||
let now = Instant::now();
|
||||
if let Some(l) = self.last {
|
||||
self.gap = self.gap.max((now - l).as_secs_f64() * 1e3);
|
||||
}
|
||||
self.last = Some(now);
|
||||
let ms = decode.as_secs_f64() * 1e3;
|
||||
(self.frames, self.skipped, self.sum, self.max) = (self.frames + 1, self.skipped + skipped.max(0) as u32, self.sum + ms, self.max.max(ms));
|
||||
let took = self.since.elapsed().as_secs_f64();
|
||||
if took >= 1.0 {
|
||||
eprintln!("raea-media: play {took:.2} s: {} frames sent of {:.0} due, {} skipped, decode avg {:.1} ms max {:.1} ms, longest gap {:.0} ms", self.frames, took * fps, self.skipped, self.sum / self.frames.max(1) as f64, self.max, self.gap);
|
||||
*self = Stats { last: self.last, ..Stats::new() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Player<'a> {
|
||||
@@ -46,7 +92,7 @@ impl<'a> Player<'a> {
|
||||
Source::Audio(a) => (a.duration(), 0.0),
|
||||
};
|
||||
let fps = if fps.is_finite() && fps > 1.0 { fps } else { 30.0 };
|
||||
Player { path, source, duration, fps, sound: None, muted: false, volume: 1.0, clock: None, looping: false, shown: None, told: None }
|
||||
Player { path, source, duration, fps, sound: None, muted: false, volume: 1.0, clock: None, looping: false, cursor: 0, lap: 0.0, skipped: 0, told: None, halvings: 0, still: Some(0.0), stats: (std::env::var("RAEA_MEDIA_STATS").as_deref() == Ok("1")).then(Stats::new) }
|
||||
}
|
||||
|
||||
/// Answers the element's asks until it's gone (its stream dropped).
|
||||
@@ -54,7 +100,7 @@ impl<'a> Player<'a> {
|
||||
loop {
|
||||
// playing: wake for the next frame; paused: wait for an ask
|
||||
let first = if self.clock.is_some() {
|
||||
match rx.recv_timeout(Duration::from_secs_f64(0.5 / self.fps)) {
|
||||
match rx.recv_timeout(self.until_next()) {
|
||||
Ok(c) => Some(c),
|
||||
Err(RecvTimeoutError::Timeout) => None,
|
||||
Err(RecvTimeoutError::Disconnected) => return self.stop(),
|
||||
@@ -84,6 +130,13 @@ impl<'a> Player<'a> {
|
||||
s.set_volume(v);
|
||||
}
|
||||
}
|
||||
Cmd::Halvings(n) => {
|
||||
// paused, the picture showing is sent again with what it is now drawn from
|
||||
if n != self.halvings && self.clock.is_none() && seek.is_none() {
|
||||
seek = self.still;
|
||||
}
|
||||
self.halvings = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
if pause && self.clock.is_some() {
|
||||
@@ -117,6 +170,47 @@ impl<'a> Player<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// How long until there is something to do: the cursor's frame comes within the lead, or the clock reaches the
|
||||
/// end. (Frames were once sent when they fell due, each after its own decode: 22 to 29 ms apart at 60 fps where
|
||||
/// 16.7 is even, a 4K frame 6.6 ms late, and a loop's first frame behind a seek; RAEA_MEDIA_STATS, 11-13.)
|
||||
fn until_next(&self) -> Duration {
|
||||
let frame = 1.0 / self.fps;
|
||||
let wait = match &self.source {
|
||||
Source::Video(_) => {
|
||||
let now = self.now();
|
||||
let decode = if self.at_end() { f64::INFINITY } else { self.cursor_time() - self.lead() - now };
|
||||
decode.min(self.duration - now).clamp(0.0005, frame)
|
||||
}
|
||||
Source::Audio(_) => 0.5 * frame,
|
||||
};
|
||||
Duration::from_secs_f64(wait)
|
||||
}
|
||||
|
||||
/// The cursor's frame's time on the clock.
|
||||
fn cursor_time(&self) -> f64 {
|
||||
self.cursor as f64 / self.fps + self.lap
|
||||
}
|
||||
|
||||
/// The cursor is past the source's last frame (a looping source's cursor goes round instead).
|
||||
fn at_end(&self) -> bool {
|
||||
!self.looping && self.duration.is_finite() && self.cursor as f64 / self.fps >= self.duration - 0.5 / self.fps
|
||||
}
|
||||
|
||||
/// How far ahead of the clock frames are decoded: a quarter second, which rides out a decode that stalls (a
|
||||
/// reader starting again, a busy machine: 40 to 85 ms seen) and the seek back to a loop's start (70 ms). No more
|
||||
/// than 128 MB of frames wait at once, 200 nearing a loop's end, and never fewer than two frames: a 4K frame
|
||||
/// sent whole is 33 MB (three wait), sent as the halving it is drawn from 8 or 2 (the quarter second).
|
||||
fn lead(&self) -> f64 {
|
||||
let frame = 1.0 / self.fps;
|
||||
let bytes = match &self.source {
|
||||
Source::Video(d) => (d.info().width as f64 * d.info().height as f64 * 4.0 / 4f64.powi(self.halvings as i32)).max(1.0),
|
||||
Source::Audio(_) => 1.0,
|
||||
};
|
||||
let near_wrap = self.looping && self.duration.is_finite() && (self.lap > 0.0 || self.duration - self.cursor as f64 * frame < 0.25);
|
||||
let most = ((if near_wrap { 200e6 } else { 128e6 }) / bytes).floor().max(2.0) * frame;
|
||||
most.min(0.25)
|
||||
}
|
||||
|
||||
/// The clock's time now.
|
||||
fn now(&self) -> f64 {
|
||||
match (&self.clock, &self.sound) {
|
||||
@@ -137,8 +231,13 @@ impl<'a> Player<'a> {
|
||||
let volume = self.volume;
|
||||
self.sound = Some(audio.and_then(|a| Sound::open(a, self.muted).inspect(|s| s.set_volume(volume)).inspect_err(|e| bevy::log::debug!("raea-runtime-js: media plays on the wall's clock: {e}")).ok()));
|
||||
}
|
||||
self.shown = None;
|
||||
(self.cursor, self.lap, self.skipped) = ((t * self.fps).floor() as i64, 0.0, 0);
|
||||
self.told = None;
|
||||
self.restart(t);
|
||||
}
|
||||
|
||||
/// The clock started at `t` (the sound from there, else the wall).
|
||||
fn restart(&mut self, t: f64) {
|
||||
self.clock = Some(match &self.sound {
|
||||
Some(Some(s)) => {
|
||||
s.start(t);
|
||||
@@ -162,30 +261,67 @@ impl<'a> Player<'a> {
|
||||
/// The frame at `t`, sent as the frame at exactly `t`; false when the element's gone.
|
||||
fn frame(&mut self, t: f64, tx: &Sender<Msg>) -> bool {
|
||||
match &mut self.source {
|
||||
Source::Video(dec) => tx.send(dec.frame_at(t).map_or_else(Msg::Fail, |f| Msg::Frame(t, f))).is_ok(),
|
||||
Source::Video(dec) => {
|
||||
self.still = Some(t);
|
||||
let n = self.halvings;
|
||||
tx.send(dec.frame_at(t).map_or_else(Msg::Fail, |f| {
|
||||
let (f, halves) = sent(f, n);
|
||||
Msg::Frame(t, f, halves)
|
||||
}))
|
||||
.is_ok()
|
||||
}
|
||||
Source::Audio(_) => tx.send(Msg::Time(t)).is_ok(),
|
||||
}
|
||||
}
|
||||
|
||||
/// One step of playing: the end (again from the start when looping), or the frame falling due now.
|
||||
/// One step of playing: the end (the clock again from the start when looping), or the cursor's frame decoded
|
||||
/// and sent with the moment it is due, once it is within the lead. One frame a step, so an ask is never kept
|
||||
/// waiting behind more than one decode.
|
||||
fn tick(&mut self, tx: &Sender<Msg>) -> bool {
|
||||
let t = self.now();
|
||||
if self.duration.is_finite() && t >= self.duration - 0.5 / self.fps {
|
||||
if self.looping {
|
||||
self.go(0.0);
|
||||
return self.frame(0.0, tx);
|
||||
let mut t = self.now();
|
||||
let frame = 1.0 / self.fps;
|
||||
if self.duration.is_finite() && self.looping && t >= self.duration {
|
||||
// round again: the frames already sent for this lap were timed on the old clock's end, which is now
|
||||
if self.lap > 0.0 {
|
||||
self.lap = 0.0;
|
||||
} else {
|
||||
self.cursor = 0;
|
||||
}
|
||||
self.restart(t - self.duration);
|
||||
t = self.now();
|
||||
} else if self.duration.is_finite() && !self.looping && t >= self.duration - 0.5 * frame {
|
||||
self.halt();
|
||||
return tx.send(Msg::Ended(self.duration)).is_ok();
|
||||
}
|
||||
match &self.source {
|
||||
Source::Video(_) => {
|
||||
let i = (t * self.fps).floor() as i64;
|
||||
if self.shown == Some(i) {
|
||||
// a looping source's cursor goes round ahead of the clock
|
||||
if self.looping && self.duration.is_finite() && self.lap == 0.0 && self.cursor as f64 * frame >= self.duration - 0.5 * frame {
|
||||
(self.cursor, self.lap) = (0, self.duration);
|
||||
}
|
||||
if self.at_end() || self.cursor_time() - self.lead() > t {
|
||||
return true;
|
||||
}
|
||||
self.shown = Some(i);
|
||||
self.frame(t, tx)
|
||||
// behind the clock by more than a frame: the frames it passed are skipped
|
||||
if self.cursor_time() + frame < t {
|
||||
let i = ((t - self.lap) * self.fps).floor() as i64;
|
||||
self.skipped += i - self.cursor;
|
||||
self.cursor = i;
|
||||
}
|
||||
let (at, due_in) = (self.cursor as f64 * frame, self.cursor_time() - t);
|
||||
let began = Instant::now();
|
||||
let Source::Video(dec) = &mut self.source else { return true };
|
||||
// asked for mid-frame: a source whose frames aren't exactly on fps's grid gives the frame showing then
|
||||
let n = self.halvings;
|
||||
let got = dec.frame_at(at + 0.5 * frame).map(|f| sent(f, n));
|
||||
let took = began.elapsed();
|
||||
let due = began + Duration::from_secs_f64(due_in.max(0.0));
|
||||
self.cursor += 1;
|
||||
if let Some(s) = self.stats.as_mut() {
|
||||
s.frame(took, std::mem::take(&mut self.skipped), self.fps);
|
||||
}
|
||||
self.still = Some(at);
|
||||
tx.send(got.map_or_else(Msg::Fail, |(f, halves)| Msg::Due(at, f, due, halves))).is_ok()
|
||||
}
|
||||
Source::Audio(_) => {
|
||||
if self.told.is_some_and(|w| w.elapsed() < Duration::from_millis(100)) {
|
||||
@@ -226,6 +362,23 @@ mod tests {
|
||||
ok.then_some(p)
|
||||
}
|
||||
|
||||
/// A halving's pixel is the mean of the four it stands for; an odd last row or column is left out; a picture a
|
||||
/// pixel wide has none; and a frame is sent whole when none are asked for.
|
||||
#[test]
|
||||
fn halvings_are_means_of_four() {
|
||||
use crate::media_html::stream::{halvings, sent};
|
||||
let px: Vec<u8> = (0..5 * 3 * 4).map(|i| (i * 3) as u8).collect();
|
||||
let h = halvings(5, 3, &px, 3);
|
||||
assert_eq!(h.iter().map(|(w, h, p)| (*w, *h, p.len())).collect::<Vec<_>>(), vec![(2, 1, 8)]);
|
||||
let mean = |x: usize, c: usize| ((px[x * 4 + c] as u16 + px[(x + 1) * 4 + c] as u16 + px[(5 + x) * 4 + c] as u16 + px[(5 + x + 1) * 4 + c] as u16 + 2) / 4) as u8;
|
||||
assert_eq!(h[0].2, vec![mean(0, 0), mean(0, 1), mean(0, 2), mean(0, 3), mean(2, 0), mean(2, 1), mean(2, 2), mean(2, 3)]);
|
||||
let f = raea_io_media::Frame { pts: 0.0, width: 5, height: 3, rgba: px.clone() };
|
||||
let (whole, none) = sent(f.clone(), 0);
|
||||
assert!(whole.rgba == px && none.is_empty());
|
||||
let (size, one) = sent(f, 1);
|
||||
assert!(size.rgba.is_empty() && (size.width, size.height) == (5, 3) && one == vec![h[0].clone()]);
|
||||
}
|
||||
|
||||
/// Played on the wall's clock (RAEA_AUDIO_MUTE=1: no device), a video's frames come as they fall due and it ends
|
||||
/// at its end; a seek answers with the frame at exactly its time; looping, it goes round; paused, it stops.
|
||||
#[test]
|
||||
@@ -235,7 +388,7 @@ mod tests {
|
||||
let Some(path) = clip() else { return eprintln!("no ffmpeg: skipped") };
|
||||
let mut st = stream::open(path.to_str().unwrap(), true).expect("a stream");
|
||||
assert!(matches!(next(&st, Duration::from_secs(10)), Some(Msg::Meta { w: 160, h: 90, .. })));
|
||||
assert!(matches!(next(&st, Duration::from_secs(5)), Some(Msg::Frame(t, _)) if t == 0.0));
|
||||
assert!(matches!(next(&st, Duration::from_secs(5)), Some(Msg::Frame(t, ..)) if t == 0.0));
|
||||
|
||||
let began = Instant::now();
|
||||
st.ask(Cmd::Play { at: 0.0, looping: false });
|
||||
@@ -243,9 +396,12 @@ mod tests {
|
||||
let (mut frames, mut last, mut ended) = (0, -1.0, None);
|
||||
while let Some(m) = next(&st, Duration::from_secs(3)) {
|
||||
match m {
|
||||
Msg::Frame(t, f) => {
|
||||
Msg::Due(t, f, due, _) => {
|
||||
assert!(t > last, "frames in order: {t} after {last}");
|
||||
assert_eq!((f.width, f.height), (160, 90));
|
||||
// each is due when its time comes on the clock (the wall's, here), sent before then
|
||||
let on_clock = due.duration_since(began).as_secs_f64();
|
||||
assert!((on_clock - t).abs() < 0.06, "the frame at {t} is due at {on_clock}");
|
||||
(frames, last) = (frames + 1, t);
|
||||
}
|
||||
Msg::Ended(t) => {
|
||||
@@ -258,17 +414,27 @@ mod tests {
|
||||
let (end, took) = ended.expect("it ended");
|
||||
assert!((end - 1.0).abs() < 0.05, "ended at its duration: {end}");
|
||||
assert!((0.85..1.4).contains(&took), "a second's clip took {took} s");
|
||||
assert!(frames >= 20, "{frames} frames of 30");
|
||||
assert!(frames >= 25, "{frames} frames of 30");
|
||||
|
||||
st.ask(Cmd::Seek(0.5));
|
||||
assert!(matches!(next(&st, Duration::from_secs(2)), Some(Msg::Frame(t, _)) if t == 0.5));
|
||||
assert!(matches!(next(&st, Duration::from_secs(2)), Some(Msg::Frame(t, ..)) if t == 0.5));
|
||||
|
||||
let looped = Instant::now();
|
||||
st.ask(Cmd::Play { at: 0.5, looping: true });
|
||||
let (mut wrapped, mut last, until) = (false, 0.5, Instant::now() + Duration::from_millis(1200));
|
||||
let (mut wrapped, mut last, mut laps, until) = (false, 0.5, 0.0, Instant::now() + Duration::from_millis(2300));
|
||||
while Instant::now() < until {
|
||||
match next(&st, Duration::from_millis(200)) {
|
||||
Some(Msg::Frame(t, _)) => {
|
||||
wrapped |= t < last;
|
||||
Some(Msg::Due(t, _, due, _)) => {
|
||||
// the first frame of the next lap is sent before the last frame of this one has gone
|
||||
if t < last {
|
||||
wrapped = true;
|
||||
laps += 1.0;
|
||||
assert!(due > Instant::now(), "the loop's first frame came after it was due");
|
||||
}
|
||||
// round the loop a frame is still due when the clock is at its time: half a second of play
|
||||
// to the end, then a second a lap
|
||||
let on_clock = due.duration_since(looped).as_secs_f64();
|
||||
assert!((on_clock - (t - 0.5 + laps)).abs() < 0.06, "lap {laps}: the frame at {t} is due {on_clock} s after play");
|
||||
last = t;
|
||||
}
|
||||
Some(Msg::Ended(_)) => panic!("a looping source doesn't end"),
|
||||
@@ -278,13 +444,20 @@ mod tests {
|
||||
assert!(wrapped, "looping went round");
|
||||
|
||||
st.ask(Cmd::Pause);
|
||||
let mut after = 0;
|
||||
while let Some(m) = next(&st, Duration::from_millis(300)) {
|
||||
if matches!(m, Msg::Frame(..)) {
|
||||
after += 1;
|
||||
// paused, asked for two halvings: the picture showing comes again as its size and its second halving
|
||||
while next(&st, Duration::from_millis(300)).is_some() {}
|
||||
st.ask(Cmd::Halvings(2));
|
||||
match next(&st, Duration::from_secs(2)) {
|
||||
Some(Msg::Frame(_, f, halves)) => {
|
||||
assert_eq!((f.width, f.height), (160, 90));
|
||||
assert!(f.rgba.is_empty(), "the frame's own pixels stay behind");
|
||||
assert_eq!(halves.iter().map(|(w, h, px)| (*w, *h, px.len())).collect::<Vec<_>>(), vec![(40, 22, 40 * 22 * 4)]);
|
||||
}
|
||||
_ => panic!("no frame with its halvings"),
|
||||
}
|
||||
assert!(after <= 1, "{after} frames after pausing");
|
||||
// what was on its way comes; then nothing more
|
||||
while next(&st, Duration::from_millis(300)).is_some() {}
|
||||
assert!(next(&st, Duration::from_millis(300)).is_none(), "frames after pausing");
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ raea-io-trace = { path = "../../io/trace" }
|
||||
raea-core-program = { path = "../../core/program" }
|
||||
raea-sys-mix = { path = "../../systems/mix" }
|
||||
raea-sys-frame = { path = "../../systems/frame" }
|
||||
raea-sys-hold = { path = "../../systems/hold" }
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app"] }
|
||||
serde_json = "1"
|
||||
wgpu = "=30.0.1"
|
||||
|
||||
@@ -16,6 +16,7 @@ mod open;
|
||||
mod sound;
|
||||
mod pointer;
|
||||
mod pick3d;
|
||||
pub use pick3d::want_wire;
|
||||
pub use sound::warm_audio;
|
||||
mod draw;
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ impl Live {
|
||||
None => json!({"owner": "", "props": {}, "text": "", "kind": "mesh"}),
|
||||
};
|
||||
out["entity"] = json!(hit.entity.to_bits());
|
||||
// where it stands (docs/scene-feed.feature SF4c): what its handles are drawn from
|
||||
if let Some(w) = self.scene.as_mut().map(|e| e.world_mut()) {
|
||||
out["placed"] = placed_json(raea_sys_hold::placed(w, hit.entity));
|
||||
}
|
||||
// how a part with no key is asked for again (locate): its entity, as text (its bits don't fit a page's number)
|
||||
out["entity_key"] = json!(format!("entity:{}", hit.entity.to_bits()));
|
||||
for (k, v) in [("part", json!(true)), ("key", json!(hit.key)), ("name", json!(hit.name)), ("rect", json!([r[0] as f64 * w, r[1] as f64 * h, r[2] as f64 * w, r[3] as f64 * h])), ("point", json!(hit.point.to_array())), ("distance", json!(hit.distance))] {
|
||||
@@ -79,6 +83,40 @@ impl Live {
|
||||
}
|
||||
}
|
||||
|
||||
/// The part a key names, as it stands now: its entity (as "entity:BITS") and where it stands. None when nothing
|
||||
/// drawn has that key. A picked part asked for again after the scene's code changed (a new world, new entities).
|
||||
pub fn part(&mut self, key: &str) -> Option<Value> {
|
||||
let w = self.scene.as_mut()?.world_mut();
|
||||
let e = raea_sys_hold::part_of(w, key)?;
|
||||
Some(json!({"entity_key": format!("entity:{}", e.to_bits()), "placed": placed_json(raea_sys_hold::placed(w, e))}))
|
||||
}
|
||||
|
||||
/// The part a key names held at a place in its parent's space (translation, rotation as a quaternion, scale), or
|
||||
/// let go of (None): drawn there until then, its code untouched. False with no 3D or no such part.
|
||||
pub fn hold(&mut self, key: &str, to: Option<([f32; 3], [f32; 4], [f32; 3])>) -> bool {
|
||||
let Some(w) = self.scene.as_mut().map(|e| e.world_mut()) else { return false };
|
||||
let Some(e) = raea_sys_hold::part_of(w, key) else { return false };
|
||||
let Some(mut held) = w.get_resource_mut::<raea_sys_hold::Held>() else { return false };
|
||||
match to {
|
||||
Some((t, r, s)) => {
|
||||
held.parts.insert(e, Transform { translation: Vec3::from(t), rotation: Quat::from_array(r).normalize(), scale: Vec3::from(s) });
|
||||
}
|
||||
None => {
|
||||
held.parts.remove(&e);
|
||||
}
|
||||
}
|
||||
self.dirty = true;
|
||||
true
|
||||
}
|
||||
|
||||
/// Every mesh drawn as its edges over its shading, or as it is. False with no 3D or no wireframe pass.
|
||||
pub fn wire(&mut self, on: bool) -> bool {
|
||||
let Some(w) = self.scene.as_mut().map(|e| e.world_mut()) else { return false };
|
||||
let ok = raea_sys_hold::set_wire(w, on);
|
||||
self.dirty |= ok;
|
||||
ok
|
||||
}
|
||||
|
||||
/// The scene drawn from an orbit (yaw and pitch in radians, distance in metres, about `target`) until None puts
|
||||
/// the composition's camera back. False with no 3D.
|
||||
pub fn set_view(&mut self, orbit: Option<(f32, f32, f32, [f32; 3])>) -> bool {
|
||||
@@ -131,3 +169,19 @@ impl Live {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a part stands, for the page: its place in its parent's space and in the world (translation, rotation as a
|
||||
/// quaternion [x, y, z, w], scale), and its parent's matrix in the world (16 numbers, column by column; null at the top).
|
||||
fn placed_json(p: raea_sys_hold::Placed) -> Value {
|
||||
let trs = |t: Transform| json!({"translation": t.translation.to_array(), "rotation": t.rotation.to_array(), "scale": t.scale.to_array()});
|
||||
json!({
|
||||
"local": trs(p.local),
|
||||
"world": trs(p.world.compute_transform()),
|
||||
"parent": p.parent.map(|g| Mat4::from(g.affine()).to_cols_array().to_vec()),
|
||||
})
|
||||
}
|
||||
|
||||
/// Scenes opened from here on can be drawn as wireframe (`Live::wire`): the app's stage asks once, before any opens.
|
||||
pub fn want_wire() {
|
||||
raea_sys_hold::want_wire();
|
||||
}
|
||||
@@ -340,9 +340,13 @@ pub fn await_models(_app: &mut App) -> Result<(), String> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn await_models(app: &mut App) -> Result<(), String> {
|
||||
let mut t0 = bevy::platform::time::Instant::now();
|
||||
let t_all = t0;
|
||||
let mut most = 0usize;
|
||||
// the cameras off while models load, so the draws are binned once, whole (#48): raea-sys-post's views.rs
|
||||
let mut off: Option<Vec<Entity>> = None;
|
||||
// RAEA_MODELS_TRACE=1: each wait that ran an update says how many and for which models (a render's frame time)
|
||||
let trace = std::env::var("RAEA_MODELS_TRACE").as_deref() == Ok("1");
|
||||
let mut pumped = 0usize;
|
||||
loop {
|
||||
let world = app.world_mut();
|
||||
if let Some(e) = world.resource_mut::<Error>().0.take() {
|
||||
@@ -367,8 +371,17 @@ pub fn await_models(app: &mut App) -> Result<(), String> {
|
||||
}
|
||||
if waiting == 0 {
|
||||
if let Some(cams) = off { raea_sys_post::views::on(app, cams); }
|
||||
if trace && pumped > 0 {
|
||||
eprintln!("raea models: waited {pumped} update(s), {:.1} ms", t_all.elapsed().as_secs_f64() * 1e3);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
if trace && pumped == 0 {
|
||||
let mut q = app.world_mut().query::<&Model3d>();
|
||||
let who: Vec<String> = q.iter(app.world()).filter(|m| !(matches!(m.state, ModelState::Ready { .. }) && m.settled())).map(|m| format!("{} ({}; surfaces {}, toon {}, shaders {})", m.id, match m.state { ModelState::Loading => "loading", ModelState::Spawned(_) => "spawned", ModelState::Ready { .. } => "ready" }, m.surfaces.len(), m.toon.len(), m.shaders.len())).take(4).collect();
|
||||
eprintln!("raea models: waiting on {waiting}: {}", who.join("; "));
|
||||
}
|
||||
pumped += 1;
|
||||
if done > most {
|
||||
most = done;
|
||||
t0 = bevy::platform::time::Instant::now();
|
||||
|
||||
+11
-6
@@ -87,6 +87,9 @@ export interface LocalTime {
|
||||
width: number;
|
||||
/** in px, what the Sequence gives its children */
|
||||
height: number;
|
||||
/** frames the subtree runs for from its frame 0, which useVideoConfig reports as durationInFrames: a Sequence's own
|
||||
* length cut where its parent's ends, a Loop's one pass, the composition's at the root */
|
||||
duration: number;
|
||||
}
|
||||
|
||||
export const ClockContext = createContext<ClockState | null>(null);
|
||||
@@ -198,8 +201,9 @@ export function useLocalTime(caller: string): LocalTime {
|
||||
useClockTick(local ? null : clock);
|
||||
if (local) return local;
|
||||
let t = rootTimes.get(clock);
|
||||
if (!t || t.frame !== clock.frame || t.width !== clock.config.width || t.height !== clock.config.height) {
|
||||
t = { frame: clock.frame, origin: 0, width: clock.config.width, height: clock.config.height };
|
||||
const c = clock.config;
|
||||
if (!t || t.frame !== clock.frame || t.width !== c.width || t.height !== c.height || t.duration !== c.durationInFrames) {
|
||||
t = { frame: clock.frame, origin: 0, width: c.width, height: c.height, duration: c.durationInFrames };
|
||||
rootTimes.set(clock, t);
|
||||
}
|
||||
return t;
|
||||
@@ -210,12 +214,13 @@ export function useCurrentFrame(): number {
|
||||
return useLocalTime("useCurrentFrame").frame;
|
||||
}
|
||||
|
||||
/** The settings of the composition being rendered (a Sequence's width and height win inside it). */
|
||||
/** The settings of the composition being rendered (inside a Sequence, its width, height and length win). */
|
||||
export function useVideoConfig(): VideoConfig {
|
||||
const clock = useClockState("useVideoConfig");
|
||||
const local = useContext(LocalTimeContext);
|
||||
if (!local || (local.width === clock.config.width && local.height === clock.config.height)) return clock.config;
|
||||
return { ...clock.config, width: local.width, height: local.height };
|
||||
const c = clock.config;
|
||||
if (!local || (local.width === c.width && local.height === c.height && local.duration === c.durationInFrames)) return c;
|
||||
return { ...c, width: local.width, height: local.height, durationInFrames: local.duration };
|
||||
}
|
||||
|
||||
export interface ClockProps {
|
||||
@@ -303,7 +308,7 @@ export function Clock(props: ClockProps) {
|
||||
if (!LITE) return <ClockContext.Provider value={state}>{props.children}</ClockContext.Provider>;
|
||||
return (
|
||||
<ClockContext.Provider value={state}>
|
||||
<LocalTimeContext.Provider value={{ frame, origin: 0, width, height }}>{props.children}</LocalTimeContext.Provider>
|
||||
<LocalTimeContext.Provider value={{ frame, origin: 0, width, height, duration: durationInFrames }}>{props.children}</LocalTimeContext.Provider>
|
||||
</ClockContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
- Keep an interior under about 50 m across. A bounce ray that goes 50 m without hitting anything counts as sky, so a
|
||||
bigger hall gets sky light in its bounce.
|
||||
- Put every light in the tree from the first frame, and change brightness with the sky, the glows and the exposure
|
||||
rather than the sun's `illuminance`. As of raea 0.1.1:
|
||||
rather than the sun's `illuminance`. As of raea 0.1.2:
|
||||
- a `DirectionalLight` that appears after the first frame lights nothing directly;
|
||||
- the traced sun keeps its first frame's strength (its direction does follow);
|
||||
- one `--at` render that jumps more than about 4.5 s between two frames loses the traced sun for every frame
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
burn none, and leave the words file beside the export for the platform's own captions.
|
||||
- Sound to -14 LUFS integrated with true peak at or below -1 dBTP: one `<Mix lufs={-14} ceiling={-1.5} />` per
|
||||
composition does it (`motion/sound`). A spec that names another number wins.
|
||||
- Render the export at `--quality master`, named in lowercase letters, digits and hyphens, with its shape and length:
|
||||
- Render the export at `--quality master` (motion graphics and type) or `--quality high` (a film), and versions made
|
||||
for notes with no `--quality` flag; name it in lowercase letters, digits and hyphens, with its shape and length:
|
||||
`spring-launch-9x16-15s.mp4`. Each version is a new file beside the last, never written over it.
|
||||
- In the raea app, post each deliverable with `feed_post` and `export: true`, tagged with the same keys across the
|
||||
project (`platform:tiktok`, `aspect:9x16`, `cut:15s`, `market:uk`): they become the project's Table, which is how
|
||||
|
||||
@@ -49,6 +49,14 @@ quality instead, each frame getting the bits it needs: `master` keeps thin type
|
||||
material as PNG frames (`RAEA_READBACK=rgba raea render piece.tsx -o frames/`) and encode them with more bits for the
|
||||
darks.
|
||||
|
||||
Which to ask for. A version made for notes (a cut to review, a shot that will be joined, a preview) takes no
|
||||
`--quality` flag: the default is already close to the picture `master` gives, in a fraction of the file. Measured on
|
||||
1080p24 film footage: the default 16 Mbit/s, `high` 30, `master` 87; against the `master` encode the default scores
|
||||
VMAF 99.5 (its worst frame 95.8) and `high` 99.7. So `master` on every review version is five times the disk for
|
||||
nothing a person sees, and a film reviewed ten times is ten gigabytes. Keep `master` for the one file that is
|
||||
delivered when it is motion graphics or type (thin edges at 4K are where it shows); deliver a film at `high`. When a
|
||||
version is replaced, delete the one before the last, and delete a shot's file once the joined film has it.
|
||||
|
||||
## A person's hand edits
|
||||
|
||||
A person's hand edit in the raea app comes back as props, so keep them when you revise: `<Composition ... edit={{
|
||||
|
||||
@@ -99,6 +99,17 @@ describe("useVideoConfig and AbsoluteFill", () => {
|
||||
at(0, <Sequence width={540} height={960}><Read /></Sequence>);
|
||||
expect(cfg).toMatchObject({ width: 540, height: 960 });
|
||||
});
|
||||
test("inside a Sequence, durationInFrames is the Sequence's", () => {
|
||||
const d: Record<string, number> = {};
|
||||
function Read({ id }: { id: string }) { d[id] = useVideoConfig().durationInFrames; return null; }
|
||||
at(15, <Sequence from={10} durationInFrames={20}><Read id="own" /></Sequence>);
|
||||
at(15, <Sequence from={10}><Read id="open" /></Sequence>);
|
||||
at(275, <Sequence from={250} durationInFrames={100}><Read id="cut" /></Sequence>);
|
||||
at(45, <Sequence from={30} durationInFrames={40}><Sequence from={5}><Read id="nested" /></Sequence></Sequence>);
|
||||
at(5, <Loop durationInFrames={12}><Read id="loop" /></Loop>);
|
||||
at(5, <Freeze frame={2}><Read id="freeze" /></Freeze>);
|
||||
expect(d).toEqual({ own: 20, open: 290, cut: 50, nested: 35, loop: 12, freeze: 300 });
|
||||
});
|
||||
test("AbsoluteFill renders its children", () => {
|
||||
at(3, <AbsoluteFill style={{ background: "black" }}><Probe id="a" /></AbsoluteFill>);
|
||||
expect(seen.a).toBe(3);
|
||||
|
||||
@@ -21,7 +21,9 @@ Feature: raea, the behaviour of its API
|
||||
And defaultProps are JSON-like values handed to the component as its props
|
||||
Scenario: What a component can ask
|
||||
Then `useVideoConfig()` returns {id, width, height, fps, durationInFrames, defaultProps} of the composition it is
|
||||
rendered in (a Sequence given width and height reports those to its children instead)
|
||||
rendered in (a Sequence given width and height reports those to its children instead, and inside a
|
||||
Sequence durationInFrames is the Sequence's: its own, cut short where its parent's ends; a Loop's children
|
||||
get one pass)
|
||||
And `useCurrentFrame()` returns the frame being rendered, measured from the start of the nearest enclosing
|
||||
Sequence (the composition's frame outside any Sequence)
|
||||
Scenario: AbsoluteFill
|
||||
|
||||
+16
-3
@@ -160,6 +160,9 @@ export function focusTo(el: Element_, tellHost: boolean) {
|
||||
transition(el, tellHost);
|
||||
}
|
||||
|
||||
/** A clip rectangle [x0, y0, x1, y1] cut to the one it's under (none: itself). */
|
||||
const within = (own: number[], under: number[] | null) => (under ? [Math.max(own[0], under[0]), Math.max(own[1], under[1]), Math.min(own[2], under[2]), Math.min(own[3], under[3])] : own);
|
||||
|
||||
/** The deepest element under (x, y), searched from `from` down: the topmost box that has the point (a higher z,
|
||||
* then the later in the tree), past what clips it and what takes no pointer events. */
|
||||
export function hit(from: Node_, x: number, y: number): Element_ | null {
|
||||
@@ -184,15 +187,25 @@ export function hit(from: Node_, x: number, y: number): Element_ | null {
|
||||
bestZ = kz;
|
||||
bestOrder = i;
|
||||
}
|
||||
if (c.overflowX !== "visible" || c.overflowY !== "visible") kclip = [b[0], b[1], b[0] + b[2], b[1] + b[3]];
|
||||
// its own clip inside the one it's under, never in its place: a card that clips (rounded corners) and lies
|
||||
// past its canvas's edge would otherwise hand its children the whole of its own box
|
||||
if (c.overflowX !== "visible" || c.overflowY !== "visible") kclip = within([b[0], b[1], b[0] + b[2], b[1] + b[3]], clip);
|
||||
} else if (b && c && kz !== z) {
|
||||
// a box with its own z-index is still under the clips of the boxes it's in: without them a card zoomed past
|
||||
// its canvas's edge took the presses on the page around the canvas (its clip was dropped here). A fixed box
|
||||
// is placed against the viewport and is under none. Not read: an absolute box whose containing block is
|
||||
// above the clipping box escapes that clip in CSS and stays under it here; a fixed box under a transformed
|
||||
// ancestor is clipped in CSS and isn't here. The host's hit test (blitz-dom's hit_inner) reads both for a
|
||||
// z-indexed box, and its answer wins where the two differ (pointed, below).
|
||||
const under = c.position === "fixed" ? null : clip;
|
||||
const inside = x >= b[0] && x < b[0] + b[2] && y >= b[1] && y < b[1] + b[3];
|
||||
if (inside && c.pointerEvents !== "none" && (kz > bestZ || (kz === bestZ && i > bestOrder))) {
|
||||
const inClip = !under || (x >= under[0] && x < under[2] && y >= under[1] && y < under[3]);
|
||||
if (inside && inClip && c.pointerEvents !== "none" && (kz > bestZ || (kz === bestZ && i > bestOrder))) {
|
||||
best = k;
|
||||
bestZ = kz;
|
||||
bestOrder = i;
|
||||
}
|
||||
kclip = c.overflowX !== "visible" || c.overflowY !== "visible" ? [b[0], b[1], b[0] + b[2], b[1] + b[3]] : null;
|
||||
kclip = c.overflowX !== "visible" || c.overflowY !== "visible" ? within([b[0], b[1], b[0] + b[2], b[1] + b[3]], under) : under;
|
||||
}
|
||||
walk(k, kclip, kz);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,38 @@ describe("P18 DOM surface", () => {
|
||||
expect(ops.some((o: any) => o.op === "update" && o.set?.scrollTop === 400)).toBe(true);
|
||||
});
|
||||
|
||||
test("a box with its own z-index stays under the overflow clip of the box it's in; a fixed one doesn't", () => {
|
||||
const host = fresh();
|
||||
function App() {
|
||||
return (
|
||||
<div data-testid="root">
|
||||
<button data-testid="side" />
|
||||
<div data-testid="stage" style={{ overflow: "hidden" }}>
|
||||
<div data-testid="view" style={{ zIndex: 2 }}>
|
||||
<div data-testid="card" style={{ zIndex: 3, overflow: "hidden" }}>
|
||||
<img data-testid="pic" />
|
||||
</div>
|
||||
</div>
|
||||
<div data-testid="menu" style={{ position: "fixed", zIndex: 5 }} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
mount(<App />, 0, { dom: true });
|
||||
// the card is zoomed past the stage's edge, over the button beside the stage; the menu is placed there on purpose
|
||||
const z = (n: number) => [...Array(12).fill(0), n];
|
||||
const boxes: Record<string, number[]> = { root: [0, 0, 800, 600], side: [0, 0, 200, 600], stage: [200, 0, 600, 600], view: [200, 0, 1600, 1200, ...z(2)], card: [100, 100, 400, 300, ...z(3)], pic: [100, 100, 400, 300, ...z(3)], menu: [20, 500, 100, 40, ...z(5)] };
|
||||
const n: number[] = [];
|
||||
for (const [t, b] of Object.entries(boxes)) n.push(host.tid(t), ...b, ...Array(17 - b.length).fill(0));
|
||||
layout(JSON.stringify({ vw: 800, vh: 600, dpr: 2, n }));
|
||||
const at = (x: number, y: number) => g.document.elementFromPoint(x, y)?.getAttribute("data-testid");
|
||||
expect(at(150, 150)).toBe("side");
|
||||
// nor do the card's own children, though the card clips too: its clip is cut to the stage's, not put in its place
|
||||
expect(at(300, 150)).toBe("pic");
|
||||
expect(at(700, 500)).toBe("view");
|
||||
expect(at(50, 510)).toBe("menu");
|
||||
});
|
||||
|
||||
test("a press goes where the host's cascade says: a child a stylesheet gives pointer events back, under a pointer-events-none layer", () => {
|
||||
const host = fresh();
|
||||
const log: string[] = [];
|
||||
|
||||
@@ -115,11 +115,11 @@ function StopsAt(props: { end: number; children?: ReactNode }) {
|
||||
}
|
||||
|
||||
/** The same LocalTime object as last render when nothing in it changed (a Freeze's subtree, a held frame). */
|
||||
function useStableTime(frame: number, origin: number, width: number, height: number): LocalTime {
|
||||
function useStableTime(frame: number, origin: number, width: number, height: number, duration: number): LocalTime {
|
||||
const r = useRef<LocalTime | null>(null);
|
||||
const p = r.current;
|
||||
if (p && p.frame === frame && p.origin === origin && p.width === width && p.height === height) return p;
|
||||
return (r.current = { frame, origin, width, height });
|
||||
if (p && p.frame === frame && p.origin === origin && p.width === width && p.height === height && p.duration === duration) return p;
|
||||
return (r.current = { frame, origin, width, height, duration });
|
||||
}
|
||||
|
||||
/** Shifts time by `from` and shows its children only for `durationInFrames` frames. */
|
||||
@@ -149,7 +149,12 @@ export function Sequence(props: SequenceProps) {
|
||||
const p = r.current;
|
||||
const w = width ?? parent.width;
|
||||
const h = height ?? parent.height;
|
||||
const time: LocalTime = p && p.frame === f - from && p.origin === parent.origin + from && p.width === w && p.height === h ? p : (r.current = { frame: f - from, origin: parent.origin + from, width: w, height: h });
|
||||
// its length: its own, cut where its parent's ends (unbounded, what's left of the parent's)
|
||||
const d = Math.min(durationInFrames, parent.duration - from);
|
||||
const time: LocalTime =
|
||||
p && p.frame === f - from && p.origin === parent.origin + from && p.width === w && p.height === h && p.duration === d
|
||||
? p
|
||||
: (r.current = { frame: f - from, origin: parent.origin + from, width: w, height: h, duration: d });
|
||||
const base = timeBase(pbase.origin + from, pbase.freeze === null ? null : pbase.freeze - from);
|
||||
// no box: the new time around the children here, as Shifted would put it (a game's sound cues, a component less each)
|
||||
if (layout === "none" && style === undefined && className === undefined) {
|
||||
@@ -259,7 +264,11 @@ export function Loop(props: LoopProps) {
|
||||
const lf = f - pass * durationInFrames;
|
||||
const lo = parent.origin + pass * durationInFrames;
|
||||
const p = r.current;
|
||||
const time: LocalTime = p && p.frame === lf && p.origin === lo && p.width === parent.width && p.height === parent.height ? p : (r.current = { frame: lf, origin: lo, width: parent.width, height: parent.height });
|
||||
// its children's length is one pass
|
||||
const time: LocalTime =
|
||||
p && p.frame === lf && p.origin === lo && p.width === parent.width && p.height === parent.height && p.duration === durationInFrames
|
||||
? p
|
||||
: (r.current = { frame: lf, origin: lo, width: parent.width, height: parent.height, duration: durationInFrames });
|
||||
const base = timeBase(pbase.origin + pass * durationInFrames, pbase.freeze === null ? null : pbase.freeze - pass * durationInFrames);
|
||||
return (
|
||||
<Shifted owner="Loop" time={time} base={base} layout={layout} style={style} className={className} label={name} stops={lo + durationInFrames}>
|
||||
@@ -280,7 +289,7 @@ export function Freeze(props: FreezeProps) {
|
||||
checkFinite("Freeze", "frame", props.frame);
|
||||
const parent = useLocalTime("Freeze");
|
||||
const pbase = useContext(TimeBaseContext);
|
||||
const time = useStableTime(props.frame, parent.origin, parent.width, parent.height);
|
||||
const time = useStableTime(props.frame, parent.origin, parent.width, parent.height, parent.duration);
|
||||
return (
|
||||
<TimeBaseContext.Provider value={timeBase(pbase.origin, props.frame)}>
|
||||
<LocalTimeContext.Provider value={time}>{props.children}</LocalTimeContext.Provider>
|
||||
|
||||
+1
-1
Submodule skills updated: 7c835cc6ca...16ed21520e.
@@ -1,10 +1,13 @@
|
||||
//! Where the encoders' files are, and their pins. SigLIP 2 and YAMNet are read from perception's models folder
|
||||
//! ($RAEA_MODELS, else ~/.local/share/raea-models) when they're there; CLAP (and SigLIP 2 on a machine without
|
||||
//! perception's copy) is fetched once from Hugging Face into raea's model cache (raea-sys-ml models.rs). YAMNet has
|
||||
//! no public ONNX source, so its column is made only where perception installed it.
|
||||
//! no public ONNX source: on a machine without perception's copy it is fetched once from the public repo's models-1
|
||||
//! release (Google's model, Apache-2.0, as ONNX) and checked against its sha256, so every machine has the same encoders
|
||||
//! and a fingerprint kept with a project judges on a teammate's fresh install (before 0.1.3 only machines with
|
||||
//! perception's copy had YAMNet, and a fingerprint trained on one refused the others).
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use raea_sys_ml::models::{Spec, ensure};
|
||||
use raea_sys_ml::models::{Spec, ensure, ensure_url};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const CLAP: Spec = Spec {
|
||||
@@ -102,7 +105,7 @@ pub fn locate() -> Result<Files> {
|
||||
let fp32 = !std::env::var("RAEA_CLAP_DTYPE").is_ok_and(|v| v == "q8");
|
||||
let c = ensure(if fp32 { &CLAP_FP32 } else { &CLAP }, &mut say).context("CLAP")?;
|
||||
let (audio, text) = if fp32 { ("audio.onnx", "text.onnx") } else { ("audio_q8.onnx", "text_q8.onnx") };
|
||||
let yam = Some(p.join("yamnet/yamnet.onnx")).filter(|f| f.is_file());
|
||||
let yam = Some(yamnet(&p)?);
|
||||
Ok(Files { sig_vision, sig_text, sig_tokenizer, clap_audio: c.join(audio), clap_text: c.join(text), clap_tokenizer: c.join("tokenizer.json"), yam })
|
||||
}
|
||||
|
||||
@@ -135,3 +138,27 @@ pub fn pin(file: &Path) -> String {
|
||||
let _ = std::fs::write(&book, serde_json::to_vec_pretty(&pins).unwrap_or_default());
|
||||
h
|
||||
}
|
||||
|
||||
/// YAMNet's ONNX export, where every machine gets it (models-1, uploaded 11-13 from perception's copy)
|
||||
const YAMNET_URL: &str = "https://github.com/shinyobjectz/raea/releases/download/models-1/yamnet.onnx";
|
||||
/// its sha256: perception's copy, so fingerprints trained where it was keep their pins
|
||||
const YAMNET_SHA256: &str = "8e4e21d5b46cfbab9082ff15aaa43065a920d31d5572834a769f77dd5e3a14ed";
|
||||
|
||||
/// YAMNet's model: perception's copy when it's here, else the one fetched once into raea's model cache, checked
|
||||
fn yamnet(perception: &Path) -> Result<PathBuf> {
|
||||
let here = perception.join("yamnet/yamnet.onnx");
|
||||
if here.is_file() {
|
||||
return Ok(here);
|
||||
}
|
||||
let cached = raea_sys_ml::models::root().join("yamnet/yamnet.onnx");
|
||||
let fresh = !cached.is_file();
|
||||
let f = ensure_url("yamnet", "yamnet.onnx", YAMNET_URL, &mut say).context("YAMNet")?;
|
||||
if fresh {
|
||||
let got = crate::media::sha256(&f)?;
|
||||
if got != YAMNET_SHA256 {
|
||||
let _ = std::fs::remove_file(&f);
|
||||
anyhow::bail!("YAMNet from {YAMNET_URL} has sha256 {got}, not {YAMNET_SHA256}; removed it");
|
||||
}
|
||||
}
|
||||
Ok(f)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ mod tests {
|
||||
use raea_sys_fingerprint::evidence::{Row, width};
|
||||
|
||||
fn row(axis: &str, source: &str, bad: bool, kind: Option<&str>) -> Row {
|
||||
Row { media: "m".into(), a: 0.0, b: 2.0, axis: axis.into(), bad, weight: 1.0, who: "me".into(), source: source.into(), project: "p".into(), kind: kind.map(Into::into), region: None, words: None, at: 0, pin: None }
|
||||
Row { media: "m".into(), a: 0.0, b: 2.0, axis: axis.into(), bad, weight: 1.0, who: "me".into(), source: source.into(), project: "p".into(), kind: kind.map(Into::into), region: None, words: None, at: 0, pin: None, band: None }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -186,10 +186,10 @@ fn own(mut w: Vec<(f64, f64, [f32; 4])>, t: f64, a: f64, b: f64, win: f64, seed:
|
||||
}
|
||||
|
||||
/// The region a note's marks name: the box around its marks, boxes and lassos (a click as a small square around it).
|
||||
/// Arrows and strikes are instructions for the agent, never a region
|
||||
/// Arrows and strikes are instructions for the agent, never a region; nor is a box on the sound (FP11c: [`sound_band`])
|
||||
pub fn marked(pin: &serde_json::Value) -> Option<[f32; 4]> {
|
||||
let mut r: Option<[f32; 4]> = None;
|
||||
for m in pin["marks"].as_array().into_iter().flatten() {
|
||||
for m in pin["marks"].as_array().into_iter().flatten().filter(|m| m["on"] != "sound") {
|
||||
let reach = match m["kind"].as_str() {
|
||||
Some("mark") => CLICK,
|
||||
Some("box" | "lasso") => 0.0,
|
||||
@@ -204,6 +204,16 @@ pub fn marked(pin: &serde_json::Value) -> Option<[f32; 4]> {
|
||||
r.filter(|a| a[2] > a[0] && a[3] > a[1])
|
||||
}
|
||||
|
||||
/// The pitch band of a box drawn on the sound's spectrogram (FP11c), low and high in 0-1 of the mel scale: its points are
|
||||
/// [time, pitch], and its time is the pin's own t..to
|
||||
pub fn sound_band(pin: &serde_json::Value) -> Option<[f32; 2]> {
|
||||
let mut boxes = pin["marks"].as_array()?.iter().filter(|m| m["kind"] == "box");
|
||||
let m = boxes.find(|m| m["on"].as_str() == Some("sound"))?;
|
||||
let p: Vec<f32> = m["points"].as_array()?.iter().filter_map(|p| p[1].as_f64()).map(|v| v.clamp(0.0, 1.0) as f32).collect();
|
||||
let (lo, hi) = (p.iter().copied().fold(f32::INFINITY, f32::min), p.iter().copied().fold(f32::NEG_INFINITY, f32::max));
|
||||
(p.len() == 2 && hi > lo).then_some([lo, hi])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -258,6 +268,10 @@ mod tests {
|
||||
assert!(near(r[0], 0.2) && near(r[1], 0.05) && near(r[2], 0.95) && near(r[3], 0.7), "{r:?}");
|
||||
assert_eq!(marked(&json!({"marks": [{"kind": "strike", "points": [[0.1, 0.1], [0.9, 0.9]]}]})), None, "a strike is for the agent");
|
||||
assert_eq!(marked(&json!({"kind": "place", "x": 0.5, "y": 0.5})), None, "a pin is never a mark");
|
||||
let sound = json!({"kind": "time", "t": 2.0, "to": 4.0, "marks": [{"kind": "box", "on": "sound", "points": [[0.2, 0.8], [0.4, 0.3]]}]});
|
||||
assert_eq!(marked(&sound), None, "a box on the sound is no place in the frame");
|
||||
assert_eq!(sound_band(&sound), Some([0.3, 0.8]), "it is a pitch band, low then high");
|
||||
assert_eq!(sound_band(&json!({"marks": [{"kind": "box", "points": [[0.1, 0.1], [0.5, 0.5]]}]})), None, "a box on the picture has none");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
//! - fixed.rs: a fix checked against the flag it claims to fix, and against the axis's disguises (FP9a)
|
||||
//! - postmortem.rs: a project looked back on, its least sure moments asked as yes/no questions (FP7a)
|
||||
//! - grow.rs: a note's mark grown into its thing and tracked over its label by EdgeTAM (FP11b)
|
||||
//! - reading.rs: a note's reading, its check, and the span and band a label takes from it (FP5b, FP11c)
|
||||
|
||||
pub mod diff;
|
||||
pub mod fixed;
|
||||
pub mod grow;
|
||||
pub mod patch;
|
||||
pub mod postmortem;
|
||||
pub mod reading;
|
||||
pub mod profile;
|
||||
pub mod realness;
|
||||
pub mod score;
|
||||
|
||||
@@ -147,7 +147,7 @@ mod tests {
|
||||
let s = Scored { file: "v1.mp4".into(), media: "h1".into(), dur: 30.0, fingerprint: "me".into(), moments: vec![], windows: vec![win(0.0, 1.5, true), win(10.0, 0.1, true), win(20.0, -1.9, false), win(11.0, 0.15, true)] };
|
||||
let mut l = Ledger::default();
|
||||
// the person approved the first moment: a flag there disagrees with them
|
||||
let r = Row { media: "h1".into(), a: 0.0, b: 2.0, axis: "*".into(), bad: false, weight: 1.0, who: "me".into(), source: "approval".into(), project: "p".into(), kind: None, region: None, words: None, at: 0, pin: None };
|
||||
let r = Row { media: "h1".into(), a: 0.0, b: 2.0, axis: "*".into(), bad: false, weight: 1.0, who: "me".into(), source: "approval".into(), project: "p".into(), kind: None, region: None, words: None, at: 0, pin: None, band: None };
|
||||
l.push(r, &vec![0.0; width()]);
|
||||
let p = picks(&[s], &trained, &fp, &l, 10);
|
||||
assert_eq!(p.iter().map(|x| (x.a, x.why.as_str())).collect::<Vec<_>>(), [(0.0, "disagrees with you"), (10.0, "least sure"), (20.0, "least sure")], "11 s is the same moment as 10 s");
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
//! A note's reading (docs/fingerprint.feature FP5a, FP5b): what a fresh agent session read a person's pinned note as
|
||||
//! (a kind and an axis), the person's check of it, and where it points: its moment or span, its marks' region in the
|
||||
//! frame (FP11b) and its box's pitch band on the sound (FP11c). Notes train only once the person has agreed with
|
||||
//! enough readings; raea-app-fingerprint's notes.rs reads them, puts them to the person and learns from them.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// FP5b's bar, out of every 50 checked
|
||||
pub const KIND_BAR: f64 = 45.0 / 50.0;
|
||||
pub const AXIS_BAR: f64 = 40.0 / 50.0;
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Reading {
|
||||
pub note: String,
|
||||
pub text: String,
|
||||
pub who: String,
|
||||
pub media: PathBuf,
|
||||
pub t: f64,
|
||||
pub project: String,
|
||||
/// defect, direction, praise or both
|
||||
pub kind: String,
|
||||
pub axis: Option<String>,
|
||||
/// how it was read: kimi or claude
|
||||
pub by: String,
|
||||
/// the person's check: Some(true) agreed, Some(false) not; None until asked
|
||||
#[serde(default)]
|
||||
pub kind_ok: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub axis_ok: Option<bool>,
|
||||
/// a span pin's end: the label covers t..to (FP11b)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub to: Option<f64>,
|
||||
/// where in the frame the note's marks say the thing is, x0,y0,x1,y1 in 0-1 (FP11b)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub region: Option<[f32; 4]>,
|
||||
/// the layers under the pin's x,y in the layer pass, on a render with one (FP5a)
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub layers: Vec<String>,
|
||||
/// a box on the sound's spectrogram: its pitch band, 0-1 of the mel scale (FP11c); its time is t..to
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub band: Option<[f32; 2]>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// The share of checked readings the person agreed with, for kind and for axis, and how many were checked
|
||||
pub fn agreement(r: &[Reading]) -> (Option<f64>, Option<f64>, usize) {
|
||||
let share = |v: Vec<bool>| (!v.is_empty()).then(|| v.iter().filter(|x| **x).count() as f64 / v.len() as f64);
|
||||
let checked = r.iter().filter(|x| x.kind_ok.is_some()).count();
|
||||
(share(r.iter().filter_map(|x| x.kind_ok).collect()), share(r.iter().filter_map(|x| x.axis_ok).collect()), checked)
|
||||
}
|
||||
|
||||
/// Whether the readings have earned training (FP5b): 50 checked, the kind right 45 times and the axis 40
|
||||
pub fn earned(r: &[Reading]) -> bool {
|
||||
matches!(agreement(r), (Some(k), Some(a), n) if n >= 50 && k >= KIND_BAR && a >= AXIS_BAR)
|
||||
}
|
||||
|
||||
/// A span pin's label: t..to inside the piece, widened about its middle to half a second when it's shorter (a box on a
|
||||
/// click of sound)
|
||||
pub fn span(t: f64, to: f64, dur: f64) -> (f64, f64) {
|
||||
let (a, b) = (t.max(0.0), to.min(dur));
|
||||
if b - a >= 0.5 {
|
||||
return (a, b);
|
||||
}
|
||||
let mid = ((a + b) / 2.0).clamp(0.25, (dur - 0.25).max(0.25));
|
||||
((mid - 0.25).max(0.0), (mid + 0.25).min(dur))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_span_is_the_label_and_a_short_one_is_widened() {
|
||||
assert_eq!(span(2.0, 4.0, 10.0), (2.0, 4.0));
|
||||
let (a, b) = span(2.0, 2.1, 10.0);
|
||||
assert!((a - 1.8).abs() < 1e-9 && (b - 2.3).abs() < 1e-9, "a box on a click of sound is half a second about it: {a}..{b}");
|
||||
assert_eq!(span(9.9, 10.0, 10.0), (9.5, 10.0), "kept inside the piece");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn notes_train_only_once_the_person_agrees_enough() {
|
||||
let r = |k: bool, a: bool| Reading { kind_ok: Some(k), axis_ok: Some(a), ..Default::default() };
|
||||
let mut v: Vec<Reading> = (0..45).map(|_| r(true, true)).collect();
|
||||
v.extend((0..5).map(|_| r(false, false)));
|
||||
assert!(earned(&v), "45 and 45 of 50");
|
||||
v[0] = r(false, true);
|
||||
assert!(!earned(&v), "44 kinds of 50 is under the bar");
|
||||
assert!(!earned(&v[..40]), "fewer than 50 checked");
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use raea_sys_fingerprint::words::Words;
|
||||
|
||||
/// A blur label in a project, its window `at` seconds in
|
||||
fn row(bad: bool, project: &str, at: f64) -> Row {
|
||||
Row { media: "m".into(), a: at, b: at + 2.0, axis: "blur".into(), bad, weight: 1.0, who: "t".into(), source: "teach".into(), project: project.into(), kind: None, region: None, words: None, at: 0, pin: None }
|
||||
Row { media: "m".into(), a: at, b: at + 2.0, axis: "blur".into(), bad, weight: 1.0, who: "t".into(), source: "teach".into(), project: project.into(), kind: None, region: None, words: None, at: 0, pin: None, band: None }
|
||||
}
|
||||
|
||||
/// Features with the label's sign in the picture's first values and a little made-up spread in the rest
|
||||
|
||||
@@ -69,6 +69,9 @@ pub struct Row {
|
||||
/// to be re-embedded or re-labelled, and no head trains on it
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub pin: Option<String>,
|
||||
/// a box on the sound's spectrogram: its pitch band, low and high in 0-1 of the mel scale up to 11.025 kHz (FP11c)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub band: Option<[f32; 2]>,
|
||||
}
|
||||
|
||||
fn one() -> f32 {
|
||||
|
||||
@@ -26,6 +26,7 @@ fn row(axis: &str, bad: bool, project: &str) -> Row {
|
||||
words: None,
|
||||
at: 0,
|
||||
pin: None,
|
||||
band: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "raea-sys-hold"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "A part of a 3D scene held where a hand has it while it is dragged, where a part stands, and the scene drawn as wireframe (docs/scene-feed.feature SF4c, SF4d, SF3e)"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render"] }
|
||||
# a part's layer key: how the app names the part it holds
|
||||
raea-sys-frame = { path = "../frame" }
|
||||
@@ -0,0 +1,142 @@
|
||||
//! A part held where a hand has it, and the scene drawn as wireframe (docs/scene-feed.feature SF4c, SF3e): while
|
||||
//! `Held` names a part, its Transform is put where the hold says after the composition's rows have placed it and
|
||||
//! before transforms propagate, so the frame draws the part (and all under it) there. Let go, it goes back to where
|
||||
//! the composition last put it. Nothing in the composition's rows changes: a hold is how a drag looks while it is
|
||||
//! dragged, and the release writes the scene's code. The same shape as the free camera (raea-sys-frame view.rs).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use bevy::pbr::wireframe::{WireframeConfig, WireframePlugin};
|
||||
use bevy::prelude::*;
|
||||
use raea_sys_frame::layer::LayerKey;
|
||||
|
||||
/// The parts held and where; and what the hold last wrote and what the composition had put there, to tell the
|
||||
/// composition's own moves from the hold's and to put each part back.
|
||||
#[derive(Resource, Default)]
|
||||
pub struct Held {
|
||||
pub parts: HashMap<Entity, Transform>,
|
||||
wrote: HashMap<Entity, Transform>,
|
||||
own: HashMap<Entity, Transform>,
|
||||
}
|
||||
|
||||
/// What an engine being built needs for both: the hold (nothing until an inspector holds a part), and Bevy's
|
||||
/// wireframe pass where a live engine's host asked for it (`want_wire`), off until `set_wire`.
|
||||
pub fn install(app: &mut App, live: bool) {
|
||||
app.init_resource::<Held>().add_systems(PostUpdate, apply.before(bevy::transform::TransformSystems::Propagate));
|
||||
if live && WIRE.get().is_some() && !app.is_plugin_added::<WireframePlugin>() {
|
||||
app.add_plugins(WireframePlugin::default());
|
||||
}
|
||||
}
|
||||
|
||||
/// PostUpdate, before transforms propagate.
|
||||
pub fn apply(mut held: ResMut<Held>, mut places: Query<&mut Transform>) {
|
||||
let Held { parts, wrote, own } = &mut *held;
|
||||
// let go of: back where the composition had it
|
||||
let gone: Vec<Entity> = wrote.keys().filter(|e| !parts.contains_key(*e)).copied().collect();
|
||||
for e in gone {
|
||||
wrote.remove(&e);
|
||||
if let (Some(o), Ok(mut t)) = (own.remove(&e), places.get_mut(e)) {
|
||||
*t = o;
|
||||
}
|
||||
}
|
||||
for (e, to) in parts.iter() {
|
||||
let Ok(mut t) = places.get_mut(*e) else { continue };
|
||||
// a transform that isn't what the hold wrote is the composition's own, placed since
|
||||
if wrote.get(e) != Some(&*t) {
|
||||
own.insert(*e, *t);
|
||||
}
|
||||
if *t != *to {
|
||||
*t = *to;
|
||||
}
|
||||
wrote.insert(*e, *to);
|
||||
}
|
||||
}
|
||||
|
||||
/// The part a key names: its LayerKey, or a part with none by its entity ("entity:BITS", as a pick names it).
|
||||
pub fn part_of(world: &mut World, key: &str) -> Option<Entity> {
|
||||
if let Some(bits) = key.strip_prefix("entity:").and_then(|b| b.parse::<u64>().ok()) {
|
||||
let mut all = world.query::<Entity>();
|
||||
return all.iter(world).find(|e| e.to_bits() == bits);
|
||||
}
|
||||
let mut keyed = world.query::<(Entity, &LayerKey)>();
|
||||
keyed.iter(world).find(|(_, k)| k.0 == key).map(|(e, _)| e)
|
||||
}
|
||||
|
||||
/// Where a part stands: in its parent's space, in the world, and its parent in the world (None at the top). What a
|
||||
/// handle is drawn from and a drag is turned into the part's own numbers with.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Placed {
|
||||
pub local: Transform,
|
||||
pub world: GlobalTransform,
|
||||
pub parent: Option<GlobalTransform>,
|
||||
}
|
||||
|
||||
pub fn placed(world: &World, e: Entity) -> Placed {
|
||||
// as the composition has it, not as a hold has moved it
|
||||
let mut local = world.get::<Transform>(e).copied().unwrap_or_default();
|
||||
if let Some(own) = world.get_resource::<Held>() {
|
||||
local = own.own.get(&e).copied().unwrap_or(local);
|
||||
}
|
||||
let mut parent = None;
|
||||
if let Some(p) = world.get::<ChildOf>(e) {
|
||||
parent = world.get::<GlobalTransform>(p.parent()).copied();
|
||||
}
|
||||
Placed { local, world: world.get::<GlobalTransform>(e).copied().unwrap_or_default(), parent }
|
||||
}
|
||||
|
||||
static WIRE: OnceLock<()> = OnceLock::new();
|
||||
|
||||
/// Live engines opened from here on can draw as wireframe (the app's stage asks; a render never does: Bevy's
|
||||
/// wireframe pass is one more pass in every frame's graph).
|
||||
pub fn want_wire() {
|
||||
WIRE.get_or_init(|| ());
|
||||
}
|
||||
|
||||
/// Every mesh drawn as its edges over its shading (on), or as it is (off). False where the engine has no wireframe
|
||||
/// pass (it wasn't asked for, or the GPU can't draw lines).
|
||||
pub fn set_wire(world: &mut World, on: bool) -> bool {
|
||||
let Some(mut c) = world.get_resource_mut::<WireframeConfig>() else { return false };
|
||||
if c.global != on {
|
||||
c.global = on;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_hold_places_the_part_and_letting_go_gives_it_back() {
|
||||
let mut app = App::new();
|
||||
install(&mut app, false);
|
||||
let own = Transform::from_xyz(1.0, 0.0, 0.0);
|
||||
let part = app.world_mut().spawn(own).id();
|
||||
app.update();
|
||||
let to = Transform::from_xyz(3.0, 2.0, 0.0);
|
||||
app.world_mut().resource_mut::<Held>().parts.insert(part, to);
|
||||
app.update();
|
||||
assert_eq!(*app.world().get::<Transform>(part).unwrap(), to);
|
||||
// where it stands in its code is still what a reader is told
|
||||
assert_eq!(placed(app.world(), part).local, own);
|
||||
// the composition moves it meanwhile: the hold stands, and that is where it goes back to
|
||||
let moved = Transform::from_xyz(5.0, 0.0, 0.0);
|
||||
*app.world_mut().get_mut::<Transform>(part).unwrap() = moved;
|
||||
app.update();
|
||||
assert_eq!(*app.world().get::<Transform>(part).unwrap(), to);
|
||||
app.world_mut().resource_mut::<Held>().parts.clear();
|
||||
app.update();
|
||||
assert_eq!(*app.world().get::<Transform>(part).unwrap(), moved);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_part_is_found_by_its_key_or_its_entity() {
|
||||
let mut world = World::new();
|
||||
let keyed = world.spawn(LayerKey("room.tsx:4:7".into())).id();
|
||||
let bare = world.spawn_empty().id();
|
||||
assert_eq!(part_of(&mut world, "room.tsx:4:7"), Some(keyed));
|
||||
assert_eq!(part_of(&mut world, &format!("entity:{}", bare.to_bits())), Some(bare));
|
||||
assert_eq!(part_of(&mut world, "room.tsx:9:9"), None);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,20 @@ pub fn ensure(spec: &Spec, progress: &mut dyn FnMut(&str, u64)) -> anyhow::Resul
|
||||
Ok(dir)
|
||||
}
|
||||
|
||||
/// One file from a URL of its own (a model with no Hugging Face home, such as YAMNet from the public repo's models-1
|
||||
/// release) into `<root>/<name>/<local>`, downloaded once. The caller checks what arrived.
|
||||
pub fn ensure_url(name: &str, local: &str, url: &str, progress: &mut dyn FnMut(&str, u64)) -> anyhow::Result<PathBuf> {
|
||||
let dir = root().join(name);
|
||||
let dest = dir.join(local);
|
||||
if dest.exists() {
|
||||
return Ok(dest);
|
||||
}
|
||||
std::fs::create_dir_all(&dir)?;
|
||||
raea_io_home::offline(&format!("the {name} model's {local} from {url}")).map_err(|e| anyhow::anyhow!(e))?;
|
||||
fetch(url, &dest, &mut |n| progress(local, n))?;
|
||||
Ok(dest)
|
||||
}
|
||||
|
||||
fn fetch(url: &str, dest: &Path, progress: &mut dyn FnMut(u64)) -> anyhow::Result<()> {
|
||||
use std::io::{Read, Write};
|
||||
let mut req = ureq::get(url);
|
||||
|
||||
@@ -434,3 +434,5 @@ pub fn menu_items(d: &BaseDocument, menu: NodeId) -> Vec<NodeId> {
|
||||
|
||||
/// Everything about an element made again (blitz-dom's ALL_DAMAGE, crate-private there): what loading an image does.
|
||||
pub const ALL_DAMAGE: style::selector_parser::RestyleDamage = style::selector_parser::RestyleDamage::from_bits_retain(0b_0000_0000_1110_1111);
|
||||
/// Only what an element is painted with changed, its box as it was: a video's next frame, the same size as its last.
|
||||
pub const REPAINT_DAMAGE: style::selector_parser::RestyleDamage = style::selector_parser::RestyleDamage::REPAINT;
|
||||
@@ -314,7 +314,13 @@ pub fn iframes() -> bool {
|
||||
std::env::var_os("RAEA_PAGE_IFRAMES").is_none_or(|v| v != "0")
|
||||
}
|
||||
|
||||
pub use ops::ALL_DAMAGE;
|
||||
pub use ops::{ALL_DAMAGE, REPAINT_DAMAGE};
|
||||
|
||||
/// A picture's halvings handed to the painter ready made (blitz-paint preload_mips): a video's frame is then drawn
|
||||
/// from the one nearest its drawn size. On the page's thread, where it is painted.
|
||||
pub fn preload_mips(image: &blitz_dom::node::RasterImageData, levels: Vec<(u32, u32, Vec<u8>)>) {
|
||||
blitz_paint::preload_mips(image, levels.into_iter().map(|(w, h, px)| blitz_dom::node::RasterImageData::new(w, h, std::sync::Arc::new(px))).collect());
|
||||
}
|
||||
|
||||
/// A document for a page `w` x `h` on its own entity: html, head and a body with no margin and no background (the
|
||||
/// page is drawn over 3D and video), which is the root the composition's elements go in. (host.rs opens a root's so.)
|
||||
|
||||
@@ -20,7 +20,9 @@ pub mod outline;
|
||||
/// A live scene's camera made before its first 3D part (MSAA off, as a 2D scene's is) multisamples once a frame brings
|
||||
/// one, as a render's camera does from its load, which sees every frame's rows (#38: kept-mount's cube mounts at frame
|
||||
/// 10 and had hard edges live). Not one whose row asks for a single-sampled frame (ssao, aa, outline, frame_looks,
|
||||
/// passes: spawn_camera's rule), and not in preview.
|
||||
/// passes: spawn_camera's rule), not in preview, and not a deferred camera (a ray-traced one): Bevy turns MSAA off
|
||||
/// on those itself each frame and says so, so this turned it on again every frame, a warning a frame in a render's
|
||||
/// log and the camera's pipelines made again for nothing.
|
||||
pub fn msaa_for_3d(world: &mut World, has_3d: bool) {
|
||||
if !has_3d || preview() {
|
||||
return;
|
||||
@@ -28,7 +30,8 @@ pub fn msaa_for_3d(world: &mut World, has_3d: bool) {
|
||||
let cams: Vec<Entity> = world.query_filtered::<Entity, With<Camera3d>>().iter(world).collect();
|
||||
for e in cams {
|
||||
let single = world.resource::<FrameRows>().vals(e).is_none_or(|v| ["ssao", "aa", "outline", "frame_looks", "passes"].iter().any(|k| v.contains_key(*k)));
|
||||
if !single && world.get::<Msaa>(e) == Some(&Msaa::Off) {
|
||||
let deferred = world.entity(e).contains::<bevy::core_pipeline::prepass::DeferredPrepass>();
|
||||
if !single && !deferred && world.get::<Msaa>(e) == Some(&Msaa::Off) {
|
||||
world.entity_mut(e).insert(Msaa::default());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ raea-sys-page = "systems"
|
||||
raea-sys-page-net = "systems"
|
||||
raea-sys-page-ops = "systems"
|
||||
raea-sys-frame = "systems"
|
||||
raea-sys-hold = "systems"
|
||||
raea-sys-splat = "systems"
|
||||
raea-sys-sprite = "systems"
|
||||
raea-sys-rt = "systems"
|
||||
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# The release build's compile cache (.github/workflows/release.yml, "Use the compile cache"): sccache on an R2 bucket
|
||||
# that every tag's build reads and writes. The job's env carries RELEASE_CACHE_ENDPOINT (the account's R2 endpoint)
|
||||
# and the bucket's key as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY; sccache is on PATH (mozilla-actions/sccache-action).
|
||||
# Each OS and architecture has its own prefix, so a key only ever names one platform's output.
|
||||
# If the bucket can't be reached, the build goes on uncached: a cache must never be why a release fails.
|
||||
set -euo pipefail
|
||||
: "${RELEASE_CACHE_ENDPOINT:?}" "${AWS_ACCESS_KEY_ID:?}" "${AWS_SECRET_ACCESS_KEY:?}" "${GITHUB_ENV:?}"
|
||||
export SCCACHE_BUCKET=raea-build-cache
|
||||
export SCCACHE_ENDPOINT="$RELEASE_CACHE_ENDPOINT"
|
||||
export SCCACHE_REGION=auto
|
||||
export SCCACHE_S3_KEY_PREFIX="release/${RUNNER_OS:-local}-${RUNNER_ARCH:-local}"
|
||||
# a request that fails mid-build compiles that crate locally instead of failing it
|
||||
export SCCACHE_IGNORE_SERVER_IO_ERROR=1
|
||||
# the server stays up for the whole build (cargo's calls are minutes apart while one crate links)
|
||||
export SCCACHE_IDLE_TIMEOUT=0
|
||||
|
||||
if ! sccache --start-server >/dev/null 2>&1; then
|
||||
echo "::warning::the compile cache didn't start; building uncached"
|
||||
exit 0
|
||||
fi
|
||||
stats=$(sccache --show-stats)
|
||||
echo "$stats" | sed -n '/Cache location/p'
|
||||
# sccache checks the bucket when it starts: a key without write access is read-only, and no access is an error
|
||||
if echo "$stats" | grep -qiE 'Cache location +s3' && ! echo "$stats" | grep -qiE 'read.?only'; then
|
||||
{
|
||||
echo "RUSTC_WRAPPER=sccache"
|
||||
for v in SCCACHE_BUCKET SCCACHE_ENDPOINT SCCACHE_REGION SCCACHE_S3_KEY_PREFIX SCCACHE_IGNORE_SERVER_IO_ERROR SCCACHE_IDLE_TIMEOUT; do
|
||||
echo "$v=${!v}"
|
||||
done
|
||||
# C and C++ in build scripts: cc-rs wraps its compiler in sccache when RUSTC_WRAPPER is sccache; CMake reads these
|
||||
echo "CMAKE_C_COMPILER_LAUNCHER=sccache"
|
||||
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache"
|
||||
} >> "$GITHUB_ENV"
|
||||
echo "compile cache on: s3://$SCCACHE_BUCKET/$SCCACHE_S3_KEY_PREFIX"
|
||||
else
|
||||
echo "::warning::the compile cache isn't writable; building uncached"
|
||||
echo "$stats"
|
||||
fi
|
||||
Executable → Regular
+16
@@ -9,4 +9,20 @@ icd=$(cygpath -w "$RUNNER_TEMP/mesa/x64/lvp_icd.x86_64.json")
|
||||
# the runner's shell is elevated, and the Vulkan loader ignores VK_DRIVER_FILES for an elevated process: the driver is
|
||||
# registered where an installed one is
|
||||
pwsh -c "New-Item -Path HKLM:\\SOFTWARE\\Khronos\\Vulkan\\Drivers -Force | Out-Null; New-ItemProperty -Path HKLM:\\SOFTWARE\\Khronos\\Vulkan\\Drivers -Name '$icd' -PropertyType DWord -Value 0 -Force | Out-Null"
|
||||
|
||||
# The Vulkan loader (Khronos, Apache 2.0) from LunarG's runtime components. GitHub's image has vulkan-1.dll in
|
||||
# System32; Namespace's Windows image doesn't, and rc6's check died there with "vulkan drivers/libraries could not be
|
||||
# loaded" and not one loader line (11-13). Its vulkaninfo proves the loader sees lavapipe before the check runs.
|
||||
rt=VulkanRT-X64-1.4.328.1-Components
|
||||
curl -fsSL -o rt.zip "https://sdk.lunarg.com/sdk/download/1.4.328.1/windows/$rt.zip"
|
||||
echo "293efbb2c11e60429df7770f40e3c5c811a7fa42af81de0cc41e8718ddb2b373 rt.zip" | sha256sum -c --quiet
|
||||
7z x -y rt.zip "$rt/x64/vulkan-1.dll" "$rt/x64/vulkaninfo.exe" >/dev/null
|
||||
sys=$(cygpath -u "$SYSTEMROOT")/System32
|
||||
if [ ! -f "$sys/vulkan-1.dll" ]; then
|
||||
cp "$rt/x64/vulkan-1.dll" "$sys/"
|
||||
echo "lavapipe: installed the Vulkan loader from $rt (the image had none)"
|
||||
fi
|
||||
out=$("$rt/x64/vulkaninfo.exe" --summary 2>&1) || true
|
||||
echo "$out" | grep -E "deviceName|driverName|apiVersion" || true
|
||||
echo "$out" | grep -qi llvmpipe || { echo "$out" | tail -40; echo "lavapipe: the Vulkan loader doesn't see lavapipe" >&2; exit 1; }
|
||||
{ echo "WGPU_BACKEND=vulkan"; echo "VK_LOADER_DEBUG=error,driver"; } >> "$GITHUB_ENV"
|
||||
Vendored
+69
@@ -1556,6 +1556,61 @@ impl Node {
|
||||
self.hit_inner(x, y, scale, &mut None)
|
||||
}
|
||||
|
||||
/// raea: whether this box's overflow clip cuts the point away (the point from its border box, unscrolled):
|
||||
/// outside its padding box on an axis it clips. The root element clips nothing (its overflow is the viewport's).
|
||||
fn clips_away(&self, x: f32, y: f32) -> bool {
|
||||
use style::values::computed::Overflow;
|
||||
let is_root_element = self.parent.and_then(|p| self.tree().get(p)).is_some_and(|p| p.parent.is_none());
|
||||
if is_root_element {
|
||||
return false;
|
||||
}
|
||||
let Some(styles) = self.primary_styles() else { return false };
|
||||
let cx = !matches!(styles.clone_overflow_x(), Overflow::Visible);
|
||||
let cy = !matches!(styles.clone_overflow_y(), Overflow::Visible);
|
||||
let (size, b) = (self.final_layout().size, self.final_layout().border);
|
||||
(cx && (x < b.left || x > size.width - b.right)) || (cy && (y < b.top || y > size.height - b.bottom))
|
||||
}
|
||||
|
||||
/// raea: whether a hoisted child (a z-index's, hit from its stacking-context root, this node) is cut away at
|
||||
/// the point (in this node's coordinates, as the hoisted children's positions are): by this node's own clip
|
||||
/// (`cut`) or by one of the boxes between along its containing blocks, the clips blitz-paint draws it under
|
||||
/// (`hoisted_clips`). A box whose containing blocks never reach this node is painted from above it, under none
|
||||
/// of these clips (blitz-paint's `from_above`), and is never cut here. Transforms on the boxes between are not
|
||||
/// read, as the painter's clips don't read them.
|
||||
fn hoisted_cut(&self, child: NodeId, x: f32, y: f32, cut: bool) -> bool {
|
||||
let tree = self.tree();
|
||||
let mut between = Vec::new();
|
||||
let mut current = tree.get(child).and_then(|n| n.containing_block());
|
||||
loop {
|
||||
match current {
|
||||
Some(id) if id == self.id => break,
|
||||
Some(id) => {
|
||||
between.push(id);
|
||||
current = tree.get(id).and_then(|n| n.containing_block());
|
||||
}
|
||||
None => return false,
|
||||
}
|
||||
}
|
||||
if cut {
|
||||
return true;
|
||||
}
|
||||
between.iter().any(|&id| {
|
||||
let Some(node) = tree.get(id) else { return false };
|
||||
// its border box from this node: its place and those of the boxes it's in, less what they're scrolled by
|
||||
let at = node.final_layout().location;
|
||||
let (mut ax, mut ay) = (at.x, at.y);
|
||||
let mut up = node.containing_block();
|
||||
while let Some(a) = up.filter(|a| *a != self.id) {
|
||||
let Some(an) = tree.get(a) else { break };
|
||||
let (l, sc) = (an.final_layout().location, an.scroll_offset());
|
||||
ax += l.x - sc.x as f32;
|
||||
ay += l.y - sc.y as f32;
|
||||
up = an.containing_block();
|
||||
}
|
||||
node.clips_away(x - ax, y - ay)
|
||||
})
|
||||
}
|
||||
|
||||
/// [`hit`](Self::hit), also resolving the innermost overlay scrollbar
|
||||
/// thumb under the point into `scrollbar` during the same descent (so
|
||||
/// thumb hit-testing shares the exact coordinate handling — transforms
|
||||
@@ -1630,6 +1685,11 @@ impl Node {
|
||||
return None;
|
||||
}
|
||||
|
||||
// raea: a box that clips its overflow takes no pointer for what it cuts away, as it draws none of it
|
||||
// (blitz-paint's `should_clip`). Blitz tested the children wherever they overflowed to, so a press on the
|
||||
// page around a zoomed canvas landed on the card that would have lain there.
|
||||
let cut = self.clips_away(x - self.scroll_offset().x as f32, y - self.scroll_offset().y as f32);
|
||||
|
||||
// Descendants overwrite, so the innermost scroll container's thumb
|
||||
// wins. Thumb coords are border-box relative (unscrolled).
|
||||
if matches_self
|
||||
@@ -1656,6 +1716,9 @@ impl Node {
|
||||
let Some(child) = self.tree().get(hoisted_child.node_id) else {
|
||||
continue;
|
||||
};
|
||||
if self.hoisted_cut(hoisted_child.node_id, x, y, cut) {
|
||||
continue;
|
||||
}
|
||||
let pos = hoisted_child.position(self.tree(), self.id);
|
||||
let x = x - pos.x;
|
||||
let y = y - pos.y;
|
||||
@@ -1668,6 +1731,9 @@ impl Node {
|
||||
|
||||
// Call `.hit()` on each child in turn. If any return `Some` then return that value. Else return `Some(self.id).
|
||||
for child_id in self.paint_children.borrow().iter().flatten().rev() {
|
||||
if cut {
|
||||
break;
|
||||
}
|
||||
let Some(child) = self.tree().get(*child_id) else {
|
||||
continue;
|
||||
};
|
||||
@@ -1699,6 +1765,9 @@ impl Node {
|
||||
let Some(child) = self.tree().get(hoisted_child.node_id) else {
|
||||
continue;
|
||||
};
|
||||
if self.hoisted_cut(hoisted_child.node_id, x, y, cut) {
|
||||
continue;
|
||||
}
|
||||
let pos = hoisted_child.position(self.tree(), self.id);
|
||||
let x = x - pos.x;
|
||||
let y = y - pos.y;
|
||||
|
||||
Vendored
+2
@@ -36,6 +36,8 @@ pub struct TilePattern {
|
||||
pub tile: kurbo::Size,
|
||||
}
|
||||
|
||||
pub use render::preload_mips;
|
||||
|
||||
/// raea: the node whose box or text the paint calls going out now draw (a glyph run, the element its text is in), for
|
||||
/// a painter that tells nodes apart: the layer pass's ID scene (raea-sys-layers, docs/review.feature R2b). None outside
|
||||
/// paint_scene.
|
||||
|
||||
Vendored
+52
-5
@@ -1516,12 +1516,49 @@ fn halve(src: &RasterImageData) -> RasterImageData {
|
||||
RasterImageData::new(w, h, Arc::new(out))
|
||||
}
|
||||
|
||||
/// The level of `image` to sample when it is drawn at `scale` of its size: the image itself, or a halving of it
|
||||
fn mip_level(image: &RasterImageData, scale: f64) -> RasterImageData {
|
||||
/// raea: halvings of an image handed over ready made, largest first: a video's frame, halved on its decoder's thread.
|
||||
/// Not every halving need be there, and the image itself may come without its pixels (only its size): it is then
|
||||
/// drawn from these alone (video_level). Kept while the image lives, as the ones made here are.
|
||||
pub fn preload_mips(image: &RasterImageData, levels: Vec<RasterImageData>) {
|
||||
MIPS.with_borrow_mut(|mips| {
|
||||
mips.retain(|_, (weak, _)| weak.upgrade().is_some());
|
||||
mips.insert(image.data.id(), (image.data.downgrade(), Some(levels)));
|
||||
});
|
||||
}
|
||||
|
||||
/// How many times `image` is halved to be sampled at `scale` of its size: the most that leaves it at least the
|
||||
/// size it is drawn.
|
||||
fn halvings_at(image: &RasterImageData, scale: f64) -> usize {
|
||||
let mut want = 0;
|
||||
while scale * f64::from(1u32 << (want + 1)) <= 1.0 && image.width >> (want + 1) >= 1 && image.height >> (want + 1) >= 1 {
|
||||
want += 1;
|
||||
}
|
||||
want
|
||||
}
|
||||
|
||||
/// A video's frame as it is drawn at `scale` of its size: nothing is halved for it here (it is a new picture each
|
||||
/// time), so of the halvings it came with (preload_mips) the smallest still at least the size mip_level would
|
||||
/// sample, else the largest. The frame itself when it came with none, or is drawn at over half its size and has
|
||||
/// its pixels.
|
||||
fn video_level(image: &RasterImageData, scale: f64) -> RasterImageData {
|
||||
let whole = image.data.data().len() >= image.width as usize * image.height as usize * 4;
|
||||
let want = halvings_at(image, scale);
|
||||
if want == 0 && whole {
|
||||
return image.clone();
|
||||
}
|
||||
MIPS.with_borrow(|mips| match mips.get(&image.data.id()) {
|
||||
Some((_, Some(levels))) if !levels.is_empty() => {
|
||||
let least = (image.width >> want).max(1);
|
||||
levels.iter().rev().find(|l| l.width >= least).unwrap_or(&levels[0]).clone()
|
||||
}
|
||||
_ => image.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
/// The level of `image` to sample when it is drawn at `scale` of its size: the image itself, or a halving of it,
|
||||
/// made now if it isn't there yet (an img's, once).
|
||||
fn mip_level(image: &RasterImageData, scale: f64) -> RasterImageData {
|
||||
let want = halvings_at(image, scale);
|
||||
if want == 0 {
|
||||
return image.clone();
|
||||
}
|
||||
@@ -2385,10 +2422,20 @@ impl ElementCx<'_, '_> {
|
||||
}
|
||||
}
|
||||
// raea: a minified <img> is drawn from its halving nearest its drawn size (mip_level); a <video>'s frames
|
||||
// are each a new picture, so they're drawn as they come, as raea's GPU-texture videos are
|
||||
// are each a new picture, so one is drawn from the halvings it came with (preload_mips), as it comes
|
||||
// when it came with none
|
||||
let outer = self.transform.determinant().abs().sqrt();
|
||||
let mip = quality != peniko::ImageQuality::Low && self.element.name.local == local_name!("img");
|
||||
let level = if mip { mip_level(image, x_scale.min(y_scale) * outer) } else { image.clone() };
|
||||
let level = if self.element.name.local == local_name!("video") {
|
||||
video_level(image, x_scale.min(y_scale) * outer)
|
||||
} else if quality != peniko::ImageQuality::Low && self.element.name.local == local_name!("img") {
|
||||
mip_level(image, x_scale.min(y_scale) * outer)
|
||||
} else {
|
||||
image.clone()
|
||||
};
|
||||
// a frame that came as its size alone, and nothing to draw it from: nothing is drawn
|
||||
if level.data.data().len() < level.width as usize * level.height as usize * 4 {
|
||||
return;
|
||||
}
|
||||
let (lx, ly) = (image.width as f64 / level.width as f64, image.height as f64 / level.height as f64);
|
||||
let image = &level;
|
||||
let transform = self
|
||||
|
||||
Reference in new issue
Block a user