Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
A click in a scene reaches the object under an overlay that covers the frame, and a part with no key is followed. A film lays a sheen or a grade over its whole picture as a page element; the pick answers the page's element when it is in front, so with one on top no click reached a 3D part. An element covering seven tenths of the frame or more now gives way to a part under the point and is answered as what is over it. locate boxes a part around its vertices as drawn (a skinned part by its pose, as a pick's own box already was) and finds a part with no LayerKey by its entity (entity:BITS, which a pick now names as entity_key), so the box of a loaded model's own mesh follows it.
shinyobjectz20a696e79365
diff --git a/docs/preview.feature b/docs/preview.featureindex 36638ca1..e1799d2c 100644--- a/docs/preview.feature+++ b/docs/preview.feature@@ -130,6 +130,10 @@ Feature: Preview: anything in a project opens at once, in its space, with its pr# is drawn is measured as posed (raea-sys-frame view bounds, from the same vertices a pick's ray meets), a# model's box counts its morph targets, its view's near plane follows its size, and the page moves the camera# out to what the stage draws. Fourteen of its models list under 3D; four were opened, a part clicked on each.+ # 11-10, pointing in a real film's compositions: a page element that covers the frame (a sheen, a grade over+ # the picture) gives way to the 3D part under the pointer and is answered as what is over it; before, it took+ # every click. A part with no key (a loaded model's own mesh) is named by its entity and its box follows it,+ # around its vertices as drawn. A script's solid is its expression until something asks for the solid.@doneScenario: PV3b. The store is managed in one placeThen Settings lists the store by project and kind with sizes, and offers Clear and Rebuild; copies whose sourcediff --git a/runtime/live/src/pick3d.rs b/runtime/live/src/pick3d.rsindex c05024ea..869ff47f 100644--- a/runtime/live/src/pick3d.rs+++ b/runtime/live/src/pick3d.rs@@ -34,6 +34,8 @@ impl Live {None => json!({"owner": "", "props": {}, "text": "", "kind": "mesh"}),};out["entity"] = json!(hit.entity.to_bits());+ // 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))] {out[k] = v;}@@ -42,7 +44,9 @@ impl Live {/// What's under the point, the page and the 3D as one picture: the page's element when it is in front of the 3D/// (with the part behind it as `under`), else the 3D's part (the page there is the 3D's holder, which shows it- /// through), else the element.+ /// through), else the element. An element that covers the frame gives way to a part under the point, and is+ /// answered as what is `over` it: a film's sheen or grade lies over the whole picture, and with it on top no+ /// click in a scene ever reached an object (every composition of a launch film, 11-10).pub fn pick(&mut self, x: f64, y: f64) -> Option<Value> {let hit = self.page.hit(x as f32, y as f32);let part = self.part_at(x, y);@@ -60,9 +64,16 @@ impl Live {if let Some(k) = e["props"].as_object().and_then(raea_sys_frame::layer::key_from_props) {e["key"] = json!(k);}- if let Some(p) = p {- e["under"] = p;+ let Some(mut p) = p else { return Some(e) };+ let covers = e["rect"].as_array().is_some_and(|r| {+ let n = |i: usize| r.get(i).and_then(Value::as_f64).unwrap_or(0.0);+ n(2) * n(3) >= 0.7 * self.w.max(1) as f64 * self.h.max(1) as f64+ });+ if covers {+ p["over"] = e;+ return Some(p);}+ e["under"] = p;Some(e)}}diff --git a/systems/frame/src/pick.rs b/systems/frame/src/pick.rsindex 5f23d446..433c2399 100644--- a/systems/frame/src/pick.rs+++ b/systems/frame/src/pick.rs@@ -69,7 +69,7 @@ pub fn part_at(world: &mut World, nx: f32, ny: f32) -> Option<PartHit> {}/// Where things are on the frame now (docs/preview.feature PV4d, PV5a): each key's part as its box (x, y, w, h in-/// 0..1; the boxes of its meshes' bounds, so it follows the part as it moves; None when it isn't drawn), and each+/// 0..1, around its meshes as drawn, so it follows the part as it moves; None when it isn't drawn), and each/// world point as its place on the frame with whether it is in front of the camera.pub fn locate(world: &mut World, keys: &[String], points: &[Vec3]) -> (Vec<Option<[f32; 4]>>, Vec<Option<[f32; 2]>>) {let mut cams = world.query_filtered::<(&Camera, &GlobalTransform), With<Camera3d>>();@@ -81,20 +81,19 @@ pub fn locate(world: &mut World, keys: &[String], points: &[Vec3]) -> (Vec<Optio};let placed: Vec<Option<[f32; 2]>> = points.iter().map(|p| on_frame(*p).map(|s| s.to_array())).collect();let mut boxes: Vec<Option<(Vec2, Vec2)>> = vec![None; keys.len()];- let mut meshes = world.query_filtered::<(Entity, &GlobalTransform, &bevy::camera::primitives::Aabb, Option<&InheritedVisibility>), With<Mesh3d>>();- for (e, place, aabb, shown) in meshes.iter(world) {- if shown.is_some_and(|s| !s.get()) {- continue;- }- let Some(k) = world.get::<LayerKey>(root_of(world, e)).and_then(|k| keys.iter().position(|x| *x == k.0)) else { continue };- let (c, h) = (Vec3::from(aabb.center), Vec3::from(aabb.half_extents));- for i in 0..8 {- let corner = c + h * Vec3::new(if i & 1 == 0 { -1.0 } else { 1.0 }, if i & 2 == 0 { -1.0 } else { 1.0 }, if i & 4 == 0 { -1.0 } else { 1.0 });- if let Some(s) = on_frame(place.transform_point(corner)) {+ // a part by its key, or one with no key (a loaded model's own mesh) by its entity ("entity:BITS", as a pick names+ // it); its box is around its vertices where the frame draws them, so a skinned part's follows its pose+ drawn(world, |world, e, posed, _| {+ let root = root_of(world, e);+ let own = world.get::<LayerKey>(root).map(|k| k.0.as_str());+ let by_entity = format!("entity:{}", root.to_bits());+ let Some(k) = keys.iter().position(|x| own == Some(x.as_str()) || *x == by_entity) else { return };+ for p in &posed {+ if let Some(s) = on_frame(*p) {boxes[k] = Some(boxes[k].map_or((s, s), |(lo, hi)| (lo.min(s), hi.max(s))));}}- }+ });let rects = boxes.into_iter().map(|b| b.map(|(lo, hi)| {let (lo, hi) = (lo.clamp(Vec2::ZERO, Vec2::ONE), hi.clamp(Vec2::ZERO, Vec2::ONE));[lo.x, lo.y, hi.x - lo.x, hi.y - lo.y]