@pixi/3d
    Preparing search index...

    Class PortalPass

    A texture portal: a second view of the scene, drawn from behind the exit and shown on the entry

    Each frame the pass stands its camera behind the exit as the viewer stands before the entry and draws the scene from there into texture. The entry's PortalMaterial shows that at the viewer's own screen position, so it reads as an opening rather than a picture. Both quads face their local +Z: the entry toward the viewer, the exit toward the room it shows. Give both the same scale: a scale only one of them has carries into the camera and resizes or stretches the far side. The wall the exit is cut into, and anything else between the camera and the exit, is left out. The pass draws nothing on frames the entry is hidden, off screen or seen from behind.

    It needs a perspective view camera and a view that isn't rotated: with an orthographic camera the far side doesn't show, and in a rotated view it doesn't line up with the opening.

    A portal that can see itself, or two that face each other, recurse one frame late per level, as any Camera3D#renderTexture that films itself does. A portal draws only while its entry is in the view camera's sight, so one seen only through another portal doesn't update.

    The far side draws only meshes in the opaque and transparent passes, with no sky: enclose the far room, or add one as PortalPass#camera shows.

    const feed = RenderTexture.create({
    width: view3d.width,
    height: view3d.height,
    format: 'rgba16float',
    });
    const geometry = new PlaneGeometry({ width: 3, height: 4 });
    const entry = new Mesh3D({ geometry, material: new PortalMaterial({ texture: feed }) });
    const exit = new Mesh3D({ geometry, material: new FlatMaterial() });
    exit.position.set(60, 0, 0);
    view3d.root.addChild(entry, exit);

    view3d.passes = [new PortalPass({ entry, exit, texture: feed })];

    Hierarchy (View Summary)

    Index
    camera: Camera3D

    The camera the far side is drawn from

    The pass adds it as a child of entry, then each frame overwrites its pose and copies the view camera's mode, fov, zoom, near, far and orthographicSize, so setting those, or its position and rotation, has no effect.

    It draws no sky. To give the feed one, add a BackgroundPass on this camera from a 'beforeOpaque' pass listed before the portal. That pass runs even on frames the portal skips. The camera's texture is cleared before its first pass each frame, so no clear pass is needed.

    class MyPortalSkyPass extends Pass3D {
    public readonly stage = 'beforeOpaque';

    public build(graph: RenderGraph, ctx: PassContext): void {
    graph.addPass(new BackgroundPass({ renderer: ctx.renderer, camera: portal.camera }));
    }
    }

    view3d.passes = [new MyPortalSkyPass(), portal];
    enabled: boolean

    Whether this pass runs

    Flipping it rebuilds the view's render graph on the next render, which suits a settings toggle but not a change every frame; animate an effect's own properties instead. It can also recompile the view's materials; View3D#passes says when.

    const wireframe = new MeshPass({ name: 'wireframe' });
    view.passes = [wireframe];
    wireframe.enabled = false;

    Readonlyentry

    entry: Mesh3D

    The quad the viewer looks through

    portal.entry.visible = false;
    
    exit: Mesh3D

    The quad on the far side; move it and the far view follows

    portal.exit.position.x += 10;
    
    requiredOutputs?: readonly SceneOutput[]

    Extra outputs the view's scene draw writes beside its colour while this pass is enabled

    Each costs the scene draw a texture and the shader work to fill it, and any output makes the view draw its scene into a texture first, as a post effect does. Reach an output's texture with RenderGraph#getSceneOutput, to read it or draw into it.

    const objectIdOutput: SceneOutput = { name: 'objectId', format: 'r32uint' };

    class MyPickingPass extends Pass3D {
    public readonly stage = 'afterTransparent';
    public readonly requiredOutputs = [objectIdOutput];
    public build(): void {}
    }
    stage: PassStage = 'beforeOpaque'

    Always 'beforeOpaque', so the feed is finished before the scene draws the entry

    const feedPasses = view3d.passes.filter((pass: Pass3D) => pass.stage === 'beforeOpaque');
    
    texture: RenderTexture

    The texture the far side is drawn into; see PortalPassOptions#texture

    const preview = new Sprite(portal.texture);
    
    • Advanced

      Adds the portal camera's opaque and transparent draws into texture

      Parameters

      Returns void

      for (const portal of portals) portal.build(graph, ctx);
      
    • Releases the camera this pass made; the feed texture and the quads are the caller's

      Returns void

      view3d.passes = [];
      portal.destroy();
      feed.destroy(true);