Skip to content

<R3F> in a box smaller than the page is projected with the page's viewport (size and centre), then clipped to the box #130

Open

Description

@Ragulsundaram

What happens

An <R3F> inside a box smaller than the page is drawn with the page's viewport: the camera's projection uses the page's size and is centred on the page's centre, and the result is then clipped to the box. So the scene is too big, off-centre, or missing, depending on where the box is.

Same scene (a 2x2 plane at the origin, camera at z = 5) in a 400x400 box at (100, 100):

Page fov Drawn Expected
400x400 (box = page) 90 80 px wide, centred 80 px wide, centred ✓
600x600 90 120 px wide (80 x 600/400), centred on the page 80 px, centred in the box
600x600 32 fills the whole box 279 px
1080x1920 90 nothing (the page's centre is outside the box) 80 px
2160x3840, box at (800, 1600) 90 fills the whole box 80 px

Expected

The camera's viewport is the <R3F>'s own box, as with R3F's <Canvas> in a browser and Remotion's <ThreeCanvas width height>: the aspect and the projection come from the box, and the box's centre is the view's centre.

Why it matters

A 3D character or object placed in part of a 2D layout (our case: a small 3D mascot that walks between cards in a 9:16 video) can't be framed today. The only way that works is a full-page <R3F>, which means rewriting every camera for the page and placing objects in world space instead of in their box.

Repro (raea 0.1.2, macOS 26.5 arm64, Apple M5 Pro)

import React from "react";
import {AbsoluteFill, Composition, registerRoot} from "raea";
import {R3F} from "raea/r3f";
const C = () => (
  <AbsoluteFill style={{background: "#00f"}}>
    <div style={{position: "absolute", left: 100, top: 100, width: 400, height: 400}}>
      <R3F flat camera={{position: [0, 0, 5], fov: 90}}>
        <mesh><boxGeometry args={[2, 2, 0.01]} /><meshBasicMaterial color="#00ff00" /></mesh>
      </R3F>
    </div>
  </AbsoluteFill>
);
registerRoot(() => <Composition id="c" component={C} width={600} height={600} fps={30} durationInFrames={1} />);

raea render c.tsx -o c.png --frame 0: the green square is 120 px wide (x 240-358). With the page set to 400x400 and the box at (0, 0) it is 80 px, as expected. At 1080x1920 nothing green is drawn.

Activity

  1. Ragulsundaram commented on Nov 15, 2026

    @Ragulsundaram
    ContributorAuthor

    @shinyobjectz please take a look at this

  2. added 4 commits that reference this issue on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions