Expand description
The portal host element: a UI rectangle that displays an offscreen render
target — the live (or snapshot) output of a Bevy camera drawing into a GPU
texture.
It is the GPU sibling of crate::canvas: both are a styled ImageNode
whose backing Image this crate manages. Where the canvas CPU-rasterizes a
display list, a portal’s image is a render target a secondary camera draws
into (render-to-texture), so a portal can embed a minimap, a picture-in-picture,
or a per-item 3D preview directly inside the React UI.
§Ownership split
This crate owns only the texture registry (RenderTargets) and the
portal↔texture binding. The consuming app owns the cameras, meshes, and
render layers: it creates a named target, spawns a
camera pointed at RenderTarget::camera_target, tags that camera with
PortalCamera, and (for snapshots) invalidates
or set_modes it. React never invents target names —
it receives them from the app over the typed event channel and echoes them back
as <portal target={name} />.
§Render model
Each target is RenderMode::Live (its camera renders every frame — minimaps,
rotating previews) or RenderMode::Snapshot (renders once when registered or
invalidated, then its camera is deactivated and the texture reused — cheap for
static thumbnails). drive_render_targets toggles Camera::is_active.
§Resolution
Each target’s Resolution is Auto (the texture is sized
to the binding portal’s laid-out box, like the canvas — crisp output and correct
camera aspect for free) or Fixed (a fixed cost, for a
target shared by several portals).
Structs§
- Portal
Camera - Marks a camera as the renderer for a named target, so
drive_render_targetscan control its activity forRenderMode::Snapshot. The app inserts it on the camera it spawns for a target. - Portal
Placeholder - A shared 1×1 transparent texture a portal shows until (and after) it is bound to a live target. Held in a resource so every unbound portal shares one image.
- RPortal
- Marks a reconciler node as a
<portal>displaying the named target. The bevy-react reconciler inserts it;bind_portalskeeps the node’sImageNodepointed at the registry’s texture for this name. - Render
Target - A handle to a freshly
created target. Usecamera_targetto point a camera at it. - Render
Target Spec - Parameters for
RenderTargets::create. - Render
Targets - The registry of named offscreen render targets. Insert it (the plugin does)
and have app systems
createtargets as game state demands.
Enums§
- Render
Mode - How often a target’s camera renders into its texture.
- Resolution
- How a target’s texture resolution is chosen.
Functions§
- bind_
portals - Point every
<portal>’sImageNodeat the texture for its target name (or the placeholder when the name isn’t registered), and record the portal as the target’s binder forResolution::Autosizing. Only writesimagewhen it actually changes, so it doesn’t needlessly re-extract the node every frame. - blank_
portal_ image - A 1×1 transparent image, mirroring
crate::canvas::blank_canvas_image. - drive_
render_ targets - Drive resolution and the snapshot lifecycle each frame:
- init_
portal_ placeholder - Create the shared
PortalPlaceholderimage at startup.