Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

R3F27: done. docs/r3f.feature R3F27 @done with its status; the r3f guide on the box's width and height and on pointer events in a live play, its "not wired yet" line gone; skills pin: raea-skills #88 (d6ba112), 3d/r3f.md the same guide

shinyobjectze8ee46d96e66
diff --git a/docs/r3f.feature b/docs/r3f.feature
index 3ffef8b5..a8254e2c 100644
--- a/docs/r3f.feature
+++ b/docs/r3f.feature
@@ -638,9 +638,29 @@ Feature: React Three Fiber both ways: an R3F scene drawn by raea, a raea composi
makes R3F's own size, its camera's aspect and an orthographic camera's frame the box's: an orthographic plane
R3F frames at zoom 40 is 80 px in a 400 x 300 box with them, 40 px without (R3F sizes it from the frame)
+ @done
Scenario: R3F27. R3F's pointer events and controls in a live play
Given an <R3F> in a game played live: meshes with onClick, onPointerOver, onPointerMove; drei's <OrbitControls>
When the player moves and clicks the pointer over the 3D
Then R3F's events fire on the mesh the pointer is over (raycast from raea's pointer through the <R3F>'s camera), and
controls move the camera, while a render (no pointer) is unchanged
And a recorded input log replays to the same frames
+ Status (11-15): done. raea's input, frame by frame, is sent to R3F's canvas as the DOM events a browser would send
+ (sdk/r3f src/input/pointer.ts): the move, the presses, a release and its click, the right button's context
+ menu, the wheel, the pointer gone, each against the frame before, with the modifier keys held. The root runs
+ R3F's own event manager on a stand-in canvas that is an event target (the renderer's domElement too), whose
+ document gets the events that bubble, so R3F raycasts each through its camera and calls the handlers on the
+ mesh it hits, and drei's <OrbitControls> (three-stdlib's, listening on the canvas and its document) turn and
+ zoom the camera. A step sends its frame's events before it renders, inside flushSync, so what a handler sets is
+ drawn that step; a render with no input sends none, and a root stepped again from frame 0 sends the same. An
+ <R3F> in a box takes the pointer in its box (page.viewBox, as events3d picks), scaled to its width and height.
+ Live play ran every composition on raea's lite runtime, which can't run R3F's reconciler: its bundle failed
+ ("use" isn't exported by lite), so an <R3F> never played live. An edit whose own sources import raea/r3f or
+ @react-three/ now plays on React, as RAEA_LIVE_REACT=1 does (raea-runtime-live needs_react; an exported game
+ the same). Measured: test/pointer.test.tsx 7/7 (over, down, a click with its point, out, a missed click; a drag
+ turning OrbitControls' camera and the wheel moving it back; the same input stepped twice ends the same); a
+ render with an input log: the ball hovered, clicked, and the box's <R3F> (400 x 400 at 100,100 of 600 x 600)
+ the same; bench/render-play's new row sdk/r3f/test/live/pointer.tsx (hover, click, a drag on the empty frame)
+ plays and renders the same frames, 1.000000 at frames 6, 12, 18 and 27, and the whole bench 13 of 13 at
+ 1.000000. Not yet: a double click, touches as pointers, a timeline baked for the player (raea-runtime-bake
+ bakes on the lite runtime)
diff --git a/sdk/guides/craft/bevy/r3f.md b/sdk/guides/craft/bevy/r3f.md
index 84b4ef7a..8f8e8502 100644
--- a/sdk/guides/craft/bevy/r3f.md
+++ b/sdk/guides/craft/bevy/r3f.md
@@ -15,7 +15,8 @@ raea add [email protected] @react-three/[email protected] # and @react-three/drei, @reac
## An R3F scene: `<R3F>`
R3F's JSX goes inside, as it would inside `<Canvas>`, and `<R3F>` takes `<Canvas>`'s settings (`camera`,
-`orthographic`, `shadows`, `flat`, `linear`, `scene`).
+`orthographic`, `shadows`, `flat`, `linear`, `scene`). In a box smaller than the frame, it's framed by its box, as
+`<Canvas>` is by its element; give it the box's `width` and `height` (frame px) so R3F's own size is the box's too.
```tsx
import { R3F } from "raea/r3f";
@@ -48,6 +49,13 @@ a frame from the composition's frame, never the wall clock, and a seek back star
a render still equals its play. `Math.random()` is seeded for the scene. raea's hooks (`useCurrentFrame`) work inside
too. Two scenes in one composition that come and go each take a `name`.
+Played live (raea 0.1.5), R3F's pointer events work as they do in a browser: `onClick`, `onPointerOver`,
+`onPointerOut`, `onPointerMove`, `onPointerDown`, `onPointerUp`, `onWheel` and `onPointerMissed` fire on the mesh under
+the pointer, and drei's `<OrbitControls>` turn and zoom the camera from the pointer and the wheel. They come from the
+play's input frame by frame, so a render given the input the play logged (`raea render --input`) draws the same
+frames, and a render with no input draws as before. An `<R3F>` in a box smaller than the frame takes the pointer in
+its box: give it the box's `width` and `height`.
+
## A plain three.js page: `<Three program>` (raea 0.1.5)
A single-file demo's script, wrapped in a function, is the program. It makes its renderer as it always did
@@ -109,7 +117,6 @@ What raea can't draw is named once in the render's output (`raea/r3f: ...`), and
(one first dispatched after the first frame isn't run either, and points and sprites don't read its buffers yet)
- a cube or 3D render target, or a target's depth texture: the target stays empty (a depth texture reads white)
- three's EffectComposer in a plain program: the scene is drawn without its passes
-- pointer events and OrbitControls in a live play: not wired yet
- an `onBeforeCompile` patch to a material other than standard or physical, or the part of one past three's lighting
(its light, its output colour): drawn without it
diff --git a/skills b/skills
index 6c8f4146..d6ba1129 160000
--- a/skills
+++ b/skills
@@ -1 +1 @@
-Subproject commit 6c8f4146a15606b6dadf10ef5cd1a5e6cd0938a9
+Subproject commit d6ba1129ef26f5a4936c65614d53ff0fcd087425